A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Save and Close Button



 
 
Thread Tools Display Modes
  #1  
Old December 24th, 2008, 12:39 AM posted to microsoft.public.access.tablesdbdesign
Rabastan
external usenet poster
 
Posts: 6
Default Save and Close Button

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
  #2  
Old December 24th, 2008, 12:47 AM posted to microsoft.public.access.tablesdbdesign
Allen Browne
external usenet poster
 
Posts: 11,706
Default Save and Close Button

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.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Rabastan" wrote in message
...
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


  #3  
Old December 24th, 2008, 02:15 AM posted to microsoft.public.access.tablesdbdesign
Steve[_57_]
external usenet poster
 
Posts: 598
Default Save and Close Button

On your new patient form you need a Close button with the following code in
the Click event:
DoCmd.Close.

On your form where you have the drop down to choose a patient, you need a
New Patient button with the following code in the Click event:
DoCmd.OpenForm "NameOfNewPatientForm",,,,acDialog

When you click this button, your new patient form will open. After you enter
the new patient and click the Close button on that form, the new patient
form will close automatically saving the new patient and then any code after
the above line of code will execute.

Steve



"Rabastan" wrote in message
...
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



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:19 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.