G
Guest
I am using BeforeUpdate events (thanks to previous posts on this forum) to
ensure users complete all the required fields on forms before the form will
save. It works fine except on one form where there is a subform. When I
complete entry on the main form and want to move to the subform to complete
the required entry, my message that "the record won't save until all items on
the form are completed" fires and the focus won't move to the subform. I
don't want the message to fire unless I haven't completed entry on the form
AND the subform. The name of my form is fHDHPAdd and the name of my subform
is fHDHPSalaryBand_subfrm. The control that must be completed on the subform
(in addition to controls on the main form) is SalaryBand. Using Access 2003.
Here is my code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim strMsg As String
If IsNull(Me![fHDHPSalaryBand subfrm].Form!SalaryBand) Then
Cancel = True
strMsg = strMsg & "Must complete data entry on this form before
record will be saved." & vbCrLf
End If
If Cancel Then
strMsg = strMsg & "Complete entry on this record or it will not be
saved."
MsgBox strMsg, vbExclamation, "Invalid data"
End If
End Sub
Can someone point out my error and a fix? Thanks.
ensure users complete all the required fields on forms before the form will
save. It works fine except on one form where there is a subform. When I
complete entry on the main form and want to move to the subform to complete
the required entry, my message that "the record won't save until all items on
the form are completed" fires and the focus won't move to the subform. I
don't want the message to fire unless I haven't completed entry on the form
AND the subform. The name of my form is fHDHPAdd and the name of my subform
is fHDHPSalaryBand_subfrm. The control that must be completed on the subform
(in addition to controls on the main form) is SalaryBand. Using Access 2003.
Here is my code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim strMsg As String
If IsNull(Me![fHDHPSalaryBand subfrm].Form!SalaryBand) Then
Cancel = True
strMsg = strMsg & "Must complete data entry on this form before
record will be saved." & vbCrLf
End If
If Cancel Then
strMsg = strMsg & "Complete entry on this record or it will not be
saved."
MsgBox strMsg, vbExclamation, "Invalid data"
End If
End Sub
Can someone point out my error and a fix? Thanks.