Close form if value null

G

Guest

Please Help! I'm trying to automatically close a form if a field value on
that form is null (meaning there are no records in the underlying table)

I tried this code but neither is working - what am I doing wrong?
(the properties of the field in question has a name of Old Check)

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.Old_Check Is Null Then DoCmd.Close
End Sub

Private Sub Old_Check_BeforeUpdate(Cancel As Integer)
If Me.Old_Check Is Null Then DoCmd.Close
End Sub

Thanks so much for any help
 
G

Guest

Thanks, I tried that, but can't figure out at which event to put it. I tried
before update, on dirty, got focus - should it be a form event or a field
event


Private Sub Form_GotFocus()
If IsNull(Me.Old_Check) = True Then DoCmd.Close


End Sub
 

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