Null Fields

K

knowshowrosegrows

I have a simple form with a few controls that are required. I have Is Not
Null validation rules that work when they tab through the form. --

I have a button with DoCmd.Close for them to close the form. Right now, if
they get a message box from the validation rule and they click OK but do not
enter the requested data and then click the close button - the form closes
and their record is lost. I want the close button to remind them they have
not entered the requested data and ask them if they want to delete the record
or enter it.

I also would like a button that they can push when they have completed the
record and want to submit it and get a blank form. What would the code for
that be?

Thanks

You all are teaching me so much
 
A

Allen Browne

To avoid the problem where the Close action/method just silently loses your
entry if it can't be saved, add a line of code that forces the record to be
saved before you close:
If Me.Dirty Then Me.Dirty = False
More info about this problem in:
Losing data when you close a form
at:
http://allenbrowne.com/bug-01.html

For a button that saves the current record and takes you to a new one, the
Click event procedure would be something like this (without error handling):

Private Sub cmdNew_Click()
If Me.Dirty Then Me.Dirty = False
If Not Me.NewRecord Then RunCommand acCmdRecordsGotoNew
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

message
news:[email protected]...
 

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