Forms Problem

  • Thread starter Thread starter Froto
  • Start date Start date
F

Froto

I would like to know what code and where I would place
it that when a user is filling out a form from the
database and does not select the submit button but rather
just closes access that it would not save the record or
prompt them that the record will not be saved to the
database.

Thank you very much for all the help
 
I would like to know what code and where I would place
it that when a user is filling out a form from the
database and does not select the submit button but rather
just closes access that it would not save the record or
prompt them that the record will not be saved to the
database.

Thank you very much for all the help

There are several ways; one is:

Put a line

Public bOKToClose As Boolean

at the top of the Form's module to create a variable accessible to all
the form's procedures.

Set it to FALSE in the Form's Current event, and to True in the Submit
button's code.

In the Form's BeforeUpdate code put something like:

Private Sub Form_BeforeUpdate(Cancel as Integer)
If Not bOkToClose Then
MsgBox "Please save the record with the Submit button", vbOKOnly
Cancel = True
End If
End Sub
 
Back
Top