Conditional format command button

  • Thread starter Thread starter Walter
  • Start date Start date
W

Walter

I have a main form on which I have a command button(#1)to
open a details subform. I also have a Yes/No control on
the main form which I want to, if selected, disable
command button #1 and enable command button #2 to open a
different details subform. I think this can be done with
the Property Let function but I am not sure how to
accomplish it.
Another thougth was to change the caption on one command
button based on the value of the Yes/No control and use an
If Then statment to open the appropriate form but this may
be more difficult.
Thanks for you're help,
Walter
 
To achieve option 1 you need to put code the AfterUpdate
event handler of the checkbox along the following lines

If {yourcheckboxname} Then
{yourcommandbutton1}.Enabled = False
{yourcommandbutton2}.Enabled = True
Else
{yourcommandbutton1}.Enabled = True
{yourcommandbutton2}.Enabled = False
End If

Regarding Option 2, I would not advocate changing the
caption on a single command button. However, if you could
come up with a caption that describes both actions, then
you can certainly use one button and make your decision as
to what happens based on the value of the checkbox e.g.

Private Sub {yourcommandbuttonname}.Click()
If {yourcheckboxname} Then
<show subform 1>
Else
<show subform 2>
End If
End Sub

Hope That Helps
Gerald Stanley MCSD
 
Back
Top