Code required for a command button

P

Paul

Hope someone can help.

I have created a command button and wish to create some code to do the
following action:

Click button to close the form and go back to frmMainMenu

Hope someone can help out.
Thanks, Paul.
 
J

John Spencer

The VBA code for this would be something like the following in its simplest
form.

Private Sub YourCommandButtonName_Click()
DoCmd.Close AcForm, Me.Name 'Close form with button
DoCmd.OpenForm "frmMainMenu" 'Open form named frmMainMenu
End Sub

--Right-Click on the button
--Select Properties
--Select Event Tab
--Select [Event Procedure] in the On Click Event
--Click on the "..." button at the end of event
--Enter the two lines of code


--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
Top