G
Guest
Hello,
I am a complete beginner and trying to make a command button that closes one
form and opens another form within the same database. I understand that a
command button can only have one action assigned to it (?) - and for multiple
actions I need to code VBA. Therefore i found this code modified it and
saved it as Module1
----------------------------------------------------------------------------------
Private Sub cmdExitForm_Click()
On Error GoTo Err_cmdExitForm_Click
'Close the customers form
DoCmd.Close acForm, "Customers", acSaveYes
'Open the contacts form view mode
DoCmd.OpenForm "Contacts", acNormal, , , acFormEdit, acWindowNormal
Exit_cmdExitForm_Click:
Exit Sub
Err_cmdExitForm_Click:
MsgBox Err.Description, vbExclamation, "Oops, something went wrong with
the command()"
Resume Exit_cmdExitForm_Click
End Su
------------------------------------------------------------------------------------
the code works as when i double click Module1 it runs and perfoms the
action. NOW i want this action to be performed OnClick of a command button
in the Customers form.
HOW DO I DO THIS?
create a macro with the RunCode? I've tried. Can some body give me step by
step instructions how to do this please?
I am a complete beginner and trying to make a command button that closes one
form and opens another form within the same database. I understand that a
command button can only have one action assigned to it (?) - and for multiple
actions I need to code VBA. Therefore i found this code modified it and
saved it as Module1
----------------------------------------------------------------------------------
Private Sub cmdExitForm_Click()
On Error GoTo Err_cmdExitForm_Click
'Close the customers form
DoCmd.Close acForm, "Customers", acSaveYes
'Open the contacts form view mode
DoCmd.OpenForm "Contacts", acNormal, , , acFormEdit, acWindowNormal
Exit_cmdExitForm_Click:
Exit Sub
Err_cmdExitForm_Click:
MsgBox Err.Description, vbExclamation, "Oops, something went wrong with
the command()"
Resume Exit_cmdExitForm_Click
End Su
------------------------------------------------------------------------------------
the code works as when i double click Module1 it runs and perfoms the
action. NOW i want this action to be performed OnClick of a command button
in the Customers form.
HOW DO I DO THIS?
create a macro with the RunCode? I've tried. Can some body give me step by
step instructions how to do this please?