Save and Close Button

R

Rabastan

I am designing a database containing patient information. On the main report
screen I have a drop down to choose the patient. I also have a button that
opens a form to add a new patient if needed. My question is how do I add a
button to "Save and Close". the new patient form after the information is
added?

Rab
 
A

Allen Browne

1. Set the command button's On Click property to:
[Event Procedure]

2. Click the Build button (...) beside this property.
Access opens the code window.

3. Between the "Private Sub..." and "End Sub", enter these 2 lines:
If Me.Dirty Then Me.Dirty = False
DoCmd.Close acForm, Me.Name

Use error handling: the first line will throw an error if the record cannot
be saved for any reason (e.g. a required field is left blank.)
 

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