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 when opening a new one 1

Status
Not open for further replies.

KerryL

Technical User
May 7, 2001
545
US
In the database I'm working on the users can go from a "search for customer" form directly to the "create new customer" form without having to go back through the switchboard.

However, the command button that opens up a new form does not close down the form they are going from. What do I need to add to the cmd button on-click event procedure so that when a user switches to a new form, the old one closes down?

DoCmd.Close frmFindCustomer.... ?
 
Try - DoCmd.Close acFrom, "FormName", acSaveNo

If there is data that needs to be saved then the last parameter could be acSaveYes or acSavePrompt

HTH,
JC
 
Thank you JC....

I didn't have the acForm syntax right and I forgot to put quotes around the form name. It's working now.

Thanks again,
KerryL
 
If you don't want to prompt the user for any kind of confirmation to save or anything then

DoCmd.Close

will work because it defaults to the current object. So if in frmBlah you have a DoCmd.Close then it will know to close frmBlah. So if you are in frmBlah and want to move to frmDuh then

DoCmd.Close
DoCmd.OpenForm "frmDuh"

in that order will close frmBlah and then open frmDuh.

Thanks to JC because I didn't know you could use arguments to DoCmd.Close to prompt user for saving automatically. I was manually using

If MsgBox("Do you want to save?", vbQuestion + _
vbYesNo, "Prompt") = vbYes Then
Save
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top