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

Button that opens and closes

Status
Not open for further replies.

NewfieGolfer

Technical User
Mar 29, 2001
80
CA
Hello All,

I was wondering if it's possible to create a button that on one click opens a form and on the second click it closes the form. If this is possible, does anyone have any idea how to create this button.

Thanks,
NG
 
In the OnClick property of the button.....

DoCmd.Close Me.Name
DoCmd.Open "Name of Form 2"

That's it.... Programming isn't a profession of choice.
It's a profession of calling...
"Hey Programmer, your application broke again!" [spin]

Robert L. Johnson III, A+, Network+, MCP
robert.l.johnson.iii@citi.com
 
Hi NG!

You can use the Tag property:

Originally set to Open then you can use this code in the click event:

If Me!YourButton.Tag = "Open" Then
DoCmd.OpenForm "YourForm"
Me!YourButton.Tag = "Close"
Else
DoCmd.Close acForm, "YourForm"
Me!YourButton.Tag = "Open"
End If

You may also want to use this code in the close event of YourForm:

Forms!FirstForm!YourButton.Tag = "Open"

In case the user finds another way to close the form without using the button.

hth
Jeff Bridgham
bridgham@purdue.edu
 
It's workin great.
Your help is appreciated
Thanks,
NG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top