Close one form and open another on oone click

kirret

New member
Local time
Today, 12:28
Joined
Apr 7, 2007
Messages
6
Hi

I'd like to know how can I create a button to close one form and open another one with 1 click.
I'd like to close "Add or Delete Customer" form and open "Add an Order and Details" form

I have 2 buttons at the moment:
To open "Add an Order and Details" I have code:

Private Sub Command118_Click()
On Error GoTo Err_Command118_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Add an Order and Details"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command118_Click:
Exit Sub

Err_Command118_Click:
MsgBox Err.Description
Resume Exit_Command118_Click

End Sub

And to close "Add or Delete Customer" form I use the normal cmd.close command:

Private Sub CloseForm_Click()
On Error GoTo Err_CloseForm_Click


DoCmd.Close

Exit_CloseForm_Click:
Exit Sub

Err_CloseForm_Click:
MsgBox Err.Description
Resume Exit_CloseForm_Click

End Sub

Can anyone help me to put these two under one button please?

Regards,

Kirret
 
Just combine the code.

It's that simple, really. ;)

W/o the error handling:

DoCmd.close
DoCmd.OpenForm criteria
 
Thanks for that :)

I've tried all different options now but still get errors with it. Could you please help me out with it

Regards,

Kirret
 
If you are still having errors, take out all your error handling and see where it errors.

What are the errors?
 
I suggest using a macro

I don't know about using code but why don't you use a macro.

You can create a macro using two actions Close & OpenForm.

The Close action will allow you to close the first form & the OpenForm action will open the form you want. Within the Close action just select the Object type form.
 
Thanks for that :)

I've tried all different options now but still get errors with it. Could you please help me out with it

Regards,

Kirret

Please be specific. If you get errors, we aren't able to help you unless you specify exactly what errors are occuring. There are thousands of possible errors that can occur in Access.
 

Users who are viewing this thread

Back
Top Bottom