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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DoCmd.Close Not Working 1

Status
Not open for further replies.
Feb 6, 2003
48
US
Hi-

I have created an Access form that shows summary level detail and when you click on a record a new form opens that has the detail information. My problem is that the main form is not closing like I want it to:

Code:
[COLOR=blue]Application.DoCmd.OpenForm "frmDetail", acNormal
Form_frmDetail.txtRptName.Value = RptName
Form_frmMain.SetFocus
Application.DoCmd.Close acForm, "Form_frmMain", acSaveNo[/color]

Line 1 opens the detail form. Line 2 populates a text box on the new form with the description of the record the user selected on the main form. The third line sets the focus back on the main form. The fourth line should close the main form but it doesn't work and I can't figure out why. This is purely cosmetic and the program will work without it, but I would like to understand why it doesn't work in this instance. I thought about setting up a close macro and calling that with DoCmd.RunMacro, but before I resort to that, I'd like to try something a bit more elegant. Thanks in advance for your help.
 
If Form_frmMain.Dirty Then Form_frmMain.UnDo
DoCmd.Close acForm, "frmMain", acSaveNo

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks for the help. All I had to do was drop the "Form_" from the form name. Its all good now. Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top