I have a form where the user will do data entry. This form also contains a subform.
I have a long If/End If statement that checks the user's data entry for errors. I then want to look at the subform to check to see if the user's data entry conflicts with the data on the subform. I can get my statements to look at the first record in the subform, but am having trouble looking at all the records in the subform. I also need to check for multiple conditions on the subform.
I've looked at other posts and tried many things, but am unsure of the correct procedure. Do I use Do/Loop or For statement? If anyone can help, it would much appreciated. Below is a simplified version of what I have. Thanks, Laurie
Dim StrMsg As String
StrMsg = "The check out information has been changed."
StrMsg = StrMsg & " Do you want to save the changes?"
If MsgBox(StrMsg, vbYesNo, "") = vbNo Then
'DoCmd.RunCommand acCmdUndo
Me.Undo
DoCmd.Close
Else
If IsNull(Me.DateOut) Then
Cancel = True
MsgBox "Message Here", vbExclamation, "Equipment Check Out"
Me.DateOut.SetFocus
ElseIf IsNull(Me.TimeOut) Then
Cancel = True
MsgBox "Message Here", vbExclamation, "Equipment Check Out"
Me.TimeOut.SetFocus
ElseIf IsNull(Me.DateProjectedReturn) Then
... (more if statements here to check data entry on main form)
... (here is where I need to check the subform records for different conditions)
ElseIf 1 check all subform records for 1st condition Then
ElseIf 2 check all subform records for 2nd condition Then
ElseIf 3 check all subform records for 3rd condition Then
I have a long If/End If statement that checks the user's data entry for errors. I then want to look at the subform to check to see if the user's data entry conflicts with the data on the subform. I can get my statements to look at the first record in the subform, but am having trouble looking at all the records in the subform. I also need to check for multiple conditions on the subform.
I've looked at other posts and tried many things, but am unsure of the correct procedure. Do I use Do/Loop or For statement? If anyone can help, it would much appreciated. Below is a simplified version of what I have. Thanks, Laurie
Dim StrMsg As String
StrMsg = "The check out information has been changed."
StrMsg = StrMsg & " Do you want to save the changes?"
If MsgBox(StrMsg, vbYesNo, "") = vbNo Then
'DoCmd.RunCommand acCmdUndo
Me.Undo
DoCmd.Close
Else
If IsNull(Me.DateOut) Then
Cancel = True
MsgBox "Message Here", vbExclamation, "Equipment Check Out"
Me.DateOut.SetFocus
ElseIf IsNull(Me.TimeOut) Then
Cancel = True
MsgBox "Message Here", vbExclamation, "Equipment Check Out"
Me.TimeOut.SetFocus
ElseIf IsNull(Me.DateProjectedReturn) Then
... (more if statements here to check data entry on main form)
... (here is where I need to check the subform records for different conditions)
ElseIf 1 check all subform records for 1st condition Then
ElseIf 2 check all subform records for 2nd condition Then
ElseIf 3 check all subform records for 3rd condition Then