Need to deactivate a command button

  • Thread starter Thread starter Melanie
  • Start date Start date
M

Melanie

Hi,
My database has a form that is a criteria checklist to
determine if the user can process a quote. What I have is
a series of checkboxes with questions, and a command
button to open the quote request form for a design quote.
The users shouldn't go to the quote request form if they
have checked any of the checkboxes, but there really isn't
anything stopping them from doing so, other than a
statement on the form.

My question is, is there any way I can deactivate the
command button if any or all of the checkboxes have been
checked, and have a popup box appear with a warning
message in it? Or is there a better way to do this whole
thing than deactivating the button?

This way, there would be no way they could get to the
quote form.

Any help from anyone is appreciated!
Melanie
 
Hi Melanie

You could use the .Enabled statement, such as:

Me.btnMybutton.Enabled = True

- OR -

Me.btnMybutton.Enabled = False

- based on the conditions that you assign.

Best regards

Maurice St-Cyr
 
Hi,
My database has a form that is a criteria checklist to
determine if the user can process a quote. What I have is
a series of checkboxes with questions, and a command
button to open the quote request form for a design quote.
The users shouldn't go to the quote request form if they
have checked any of the checkboxes, but there really isn't
anything stopping them from doing so, other than a
statement on the form.

My question is, is there any way I can deactivate the
command button if any or all of the checkboxes have been
checked, and have a popup box appear with a warning
message in it? Or is there a better way to do this whole
thing than deactivating the button?

This way, there would be no way they could get to the
quote form.

Any help from anyone is appreciated!
Melanie

Have the command button disabled by default.
Then you might use a procedure like the following ...

Private Sub AllowOpenForm()
Me.cmdButtonName.Enabled = (Me.chk1 + Me.chk2 + Me.chk3) = 0
End Sub

Change the names to fit yours and put all of the check boxes between
the parenthesis. Call the sub from each of the checkbox's AfterUpdate
event, and also on the form's Current event.

Or with the warning message ...

Private Sub AllowOpenForm()
If (Me.chk1 + Me.chk2 + Me.chk3) < 0
Me.cmdButtonName.Enabled = False
MsgBox "Warning, Warning"
Else
Me.cmdButtonName.Enabled = True
End If
End Sub


- Jim
 
Jim,
Thanks for the code! It is working, sort of. When I
check the box, the command button is disabled and my
message pops up, but if I uncheck the box again, the
command button is still disabled. How do I get it to be
enabled again if the box is unchecked?
Thanks for your help,
Melanie
 
Melanie,
Which one? How about copying and posting the actual code you are
using.

- Jim
 
Jim,
I tweaked it around a bit, and it works fine now. Thanks
for all your help!
Melanie
 
Back
Top