Check Data on Continuous Form

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
********
 
K

Ken Snell MVP

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
 
S

Sash

Thanks Ken. I'm getting a Compile Error: Method or data member not found on
the "me.rti_status.backcolor = vbred"

Any ideas?
 
K

Ken Snell MVP

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top