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

close active form and open another form w/button

Status
Not open for further replies.

cwash

Technical User
May 27, 2002
45
0
0
US
How do I make a button close the active form and open another form? Basically, I have a form with a button, that "on click" will take me to the "main form." I want that same button to also close the active form.

So, how do I get a button to have two actions, close the active form and then open another form?

I am new at Access, so if possible, please explain on the assumption you are speaking to a newbee.

TIA
 
What is the actual VBA code of your button's Click event procedure ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
The 'opnMain' is the button on the active form- the "main" form opens, but the active form remains open.

Private Sub opnMain_Click()
On Error GoTo Err_opnMain_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmMain"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_opnMain_Click:
Exit Sub

Err_opnMain_Click:
MsgBox Err.Description
Resume Exit_opnMain_Click

End Sub
 
you may try this:
Code:
Private Sub opnMain_Click()
On Error GoTo Err_opnMain_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "frmMain"
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    [!]DoCmd.Close acForm, Me.Name[/!]

Exit_opnMain_Click:
    Exit Sub

Err_opnMain_Click:
    MsgBox Err.Description
    Resume Exit_opnMain_Click
    
End Sub

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
PH-

Does my form name replace the "Me" or the "Name"? (or do I leave the Me.Name as they are?

I'm referring to the line below.


DoCmd.Close acForm, Me.Name

TIA

 
What happens if you leave the Me.Name as they are?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I was getting an "argument" an "object" msg when I orginally left it as is, so I replaced the Me and Name (independantly) with my form name but was still getting the msgs.

I then reverted back to your Me.Name and now it works!! I don't know what I did, but now it works!

PH...Thank you very much!!



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top