Forms Problem

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
 
J

John Vinson

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
 

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