Check Data on Continuous Form

  • Thread starter Thread starter Sash
  • Start date Start date
S

Sash

Is there an easy way to check that data has been completed on continuous
form? I have the following code, but it's only looking at the first record.

'Check field RTI_Status for data. If there is no data, make field RED
Dim StNoClose As String
If IsNull(Me!frmDailyData!rti_status) Then
MsgBox "Missing Status for Records"
Me!frmDailyData!rti_status.BackColor = vbRed
StNoClose = "X"
End If

'If something is missing cancel the click
If StNoClose = "X" Then
Cancel = True
Else
********
Do a buncho of other stuff
********
 
You have to loop through the form's data:

'Check field RTI_Status for data. If there is no data, make field RED
Dim StNoClose As String
With Me.RecordsetClone
.MoveFirst
Do While .EOF = False
If IsNull(.rti_status) Then
MsgBox "Missing Status for Records"
Me.Bookmark = .Bookmark
Me.rti_status.BackColor = vbRed
StNoClose = "X"
Exit Do
End If
Loop
End With

'If something is missing cancel the click
If StNoClose = "X" Then
Cancel = True
Else
********
Do a buncho of other stuff
********
End If
 
Thanks Ken. I'm getting a Compile Error: Method or data member not found on
the "me.rti_status.backcolor = vbred"

Any ideas?
 
Sorry, I just realized that this code is running in the main form, and is
checking data in the subform on that main form. Revised code is below.

Also, you'll need to add code to your subform that sets the BackColor
property to vbWhite in the control's AfterUpdate event.

'Check field RTI_Status for data. If there is no data, make field RED
Dim StNoClose As String
With Me!frmDailyData.Form
RecordsetClone.MoveFirst
Do While RecordsetClone.EOF = False
If IsNull(RecordsetClone.rti_status) Then
MsgBox "Missing Status for Records"
.Bookmark = RecordsetClone.Bookmark
.rti_status.BackColor = vbRed
StNoClose = "X"
Exit Do
End If
Loop
End With

'If something is missing cancel the click
If StNoClose = "X" Then
Cancel = True
Else
********
Do a buncho of other stuff
********
End If
 
Back
Top