Hi there. I've posted this before but haven't got an answer yet. Really urgent that i figure this out...
I have subforms embedded in a master form. I don't want them to close the master form until they're finished filling out certain fields on the sub form.
I've tried the following on the master form close event:
Private Sub Form_Close()
'Jan 30. Prevent from closing if key fields missing.
If Me.[Enrolled].Value = "" Then
MsgBox ("You must specify whether this participant has been enrolled or not!")
DoCmd.CancelEvent
Exit Sub
Else
'check form 4
If IsNull(frmInclExclSection4.Controls.Item(6).Value) Then
frmInclExclSection4.SetFocus
MsgBox ("Section 4 hasn't been reviewed.")
DoCmd.CancelEvent
End If
End If
But the DOCMD.CANCELEVENT doesn't stop the form from closing. Where do i have to put this code to prevent the user from saving the record without these key fields?
Thanks.
I have subforms embedded in a master form. I don't want them to close the master form until they're finished filling out certain fields on the sub form.
I've tried the following on the master form close event:
Private Sub Form_Close()
'Jan 30. Prevent from closing if key fields missing.
If Me.[Enrolled].Value = "" Then
MsgBox ("You must specify whether this participant has been enrolled or not!")
DoCmd.CancelEvent
Exit Sub
Else
'check form 4
If IsNull(frmInclExclSection4.Controls.Item(6).Value) Then
frmInclExclSection4.SetFocus
MsgBox ("Section 4 hasn't been reviewed.")
DoCmd.CancelEvent
End If
End If
But the DOCMD.CANCELEVENT doesn't stop the form from closing. Where do i have to put this code to prevent the user from saving the record without these key fields?
Thanks.