Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Close Form, Don't Save!!

Status
Not open for further replies.

Acipenser

Technical User
Oct 15, 2001
39
US
I have a form "A" that gets information for 2 fields (there are more for the user to enter)from a previous form "B". When form "A" opens the information is already in the fields. What I want to do is put in a Cancel button so that the user can close form "A" and not save the data if they accidently opened form "A". I have a button made with the close command, and have searched these forums for ways to not save, but have not found any that work. Could someone give me a good way to close the form without saving?
 
Hi!

Have you tried Me.Undo before the close command?

hth Jeff Bridgham
bridgham@purdue.edu
 
Yes, I tried that. Did not seem to have an effect.

Information is saved in 2 fields. The first is a autonumber primary key field. The second is the number for SampleStrawID. No other fields are saved.

Here is the code used to open the form:
stDocName = "frmFieldReport"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord , , acNewRec
Forms![frmFieldReport]![SampleStrawID] = Forms![frmFieldStrawRpt]![SampleStrawID]

Here is the code presently used to close the form:
DoCmd.Close acDefault, , acSaveNo

If I put in the command acSavePrompt, it will prompt me to save, and if I click no, it saves anyway.

Any other suggestions?

 
Hi!

Try putting:

DoCmd.GoToRecord , , acNewRec
Forms![frmFieldReport]![SampleStrawID] = Forms![frmFieldStrawRpt]![SampleStrawID]

into the Open event procedure ot frmFieldReport.

hth Jeff Bridgham
bridgham@purdue.edu
 
I am an idiot, or at least it appears that way. I tried the Me.Undo command last night with no success.

I re-tried it today after reading your post and after responding to your post. It works now. I guess I forgot to save the change in code before trying the form again? Anyway it is working now, and I really appreciate your help.

Boy can debugging be a pain in the rear!!

Thanks again.
 
Hi!

A pain, yes! But nothing feels better than solving a problem! :)

Jeff Bridgham
bridgham@purdue.edu
 
Hi,
I have exactly the same problem as Acipenser had but with a slight difference.Here it is:
I have a form "A" that gets information for 2 fields (there are more for the user to enter)from a previous form "B". When form "A" opens the information is already in those 2 fields. What I want to do is when the user enters data into other fields, I want form "A" to save all the new data entered ,except the 2 fields already there from the form "B".
Any help is appreciated.
Thanks,
Madhu.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top