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

Command Button question 1

Status
Not open for further replies.

mwmarks

IS-IT--Management
Jan 28, 2001
9
US
I'm new to Access programming and am having a problem with a command button on a form. I have an event procedure assigned to the on_click event for the command button. The procedure executes properly but when I return to the form, the command button remains greyed-out just as when it was clicked rather than returning to normal. What must be done in order to restore it? Thanks.
 
Hi!

Normally nothing needs to be done to restore the button's functionality. Could you post the code you are using in the Click procedure.

Jeff Bridgham
bridgham@purdue.edu
 
The problem occurs when I do something as simple as using command buttons to navigate between forms that I'm using as menus. On my main menu form (frm_MainMenu) I have a command button "cmdCreateNewForecast." In the on_click event I have the following code:

Private Sub cmdCreateNewForecast_Click()
Me.Visible = False
DoCmd.OpenForm "frm_ForecastParameters"
End Sub

This opens the form "frm_ForecastParameters" successfully. I have a command button cmdCancel on this form that returns to frm_MainMenu. cmdCancel has the following code in the on_click event:

Private Sub cmdCancel_Click()
Me.Visible = False
DoCmd.OpenForm "frm_MainMenu"
End Sub

It also functions properly but when I am returned to frm_MainMenu the command button that I originally clicked remains greyed (pushed). If I click on it it is functional and will take me to the frm_CreateNewForecast again but the cmdCancel command button on this form is also remains greyed (pushed), although it remains functional too.

I was expecting to see the buttons restored to the "up" position when I move from form to form. ...must be something simple but it has me baffled.

I'm using Access 97. Thanks for the help.
 
Private Sub cmdCancel_Click()
Me.Visible = False
DoCmd.OpenForm "frm_MainMenu"
End Sub

There's your problem right there. Don't RE OPEN the menu form, just make it visible again.

Remember, you're unique - just like everyone else
You're invited to visit another free Access forum:
or my site,
 
Thanks Jim. I couldn't figure out how to change the .Visible property but I changed it to do a Form Open and Close and it worked. --mm
 
Try something like this in your navigational buttons:

~~~~~~~~~~~~~~~
Me.Visible = Not Me.Visible
Docmd.OpenForm "{target form name}" ....
~~~~~~~~~~~~~~~

and on the other target form, if you return to the first form directly:

Me.Visible = Not Me.Visible
{FirstFormName}.Visible = Not Me.Visible

Some apps go through the process of opening all the forms at startup, in the 'hidden' mode, and then make them visible when needed. This is nice,IF your data lends itself to this. Or open the three or four main forms that you use. Depends on the way the application runs.
Code:
DoCmd.OpenForm "{formname}" , , , , , acHidden

Thats FIVE commas, if you don't have any other run-time parameters to pass along.

Note that setting the Visible Property to its' negative turns the form visible if its currently hidden, and hides it if its currently visible.




Remember, you're unique - just like everyone else
You're invited to visit another free Access forum:
or my site,
 
Thanks Jim, this was very helpful. It was an improvement to open them all at startup and change the .visible property. --mm
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top