How can I Enable a Check Box based on another fields value?

D

David Saywell

Hi There,

I have a form with a disabled check box. I need to enable it when a certain
value ("approved") is selected from a combo box.

When I am in Form Design View and I have the Check Box selected the
Conditional Formatting menu item on the Format menu is greyed out.

I am using Access 2003.

Can you tell me what I need to do to make this work?

Many thanks,

David
 
L

Linq Adams via AccessMonster.com

As you've discovered, Conditional Formatting isn't availabe to checkboxes.

Try this:

Private Sub Form_Current()
If Me.YourComboBox = "Approved" Then
YourCheckBox.Enabled = True
Else
YourCheckBox.Enabled = False
End If
End Sub

Private Sub YourComboBox_AfterUpdate()
If Me.YourComboBox = "Approved" Then
YourCheckBox.Enabled = True
Else
YourCheckBox = 0 ' If "Approval" is rescinded unchecks
YourCheckBox.Enabled = False
End If
End Sub

The line

YourCheckBox = 0

was placed under the assumption that if "approved" was selected and the
checkbox enabled, then checked, and the "approved" status was found to be
incorrect, you would also want the checkbox unchecked. IF this is incorrect
for your needs, simply delete this line.

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
 
D

David Saywell

Hi Again,

I managed to find a partial solution:

From: "Jeff Boyce" <[email protected]_HYPHEN_TO_END>
References: <[email protected]>
Subject: Re: Enable or Disable Checkbox with expression builder
Date: Fri, 4 Jan 2008 06:57:00 -0800

Accordingly to solve my problem I disabled my Checkbox by default. I then
created an Event Procedure for the On Change Event of my Combo Box using the
following code:

Private Sub ComboBox_Change()

If Me!Status = "Approved" Then

Me!CheckBox.Enabled = (Me!Status = "Approved")

Else

Me!CheckBox.Enabled = False

End If

End Sub

This means that my Check Box is only Active when the ComboBox value =
"Approved".

Hope this helps...

David
 
F

fredg

Hi There,

I have a form with a disabled check box. I need to enable it when a certain
value ("approved") is selected from a combo box.

When I am in Form Design View and I have the Check Box selected the
Conditional Formatting menu item on the Format menu is greyed out.

I am using Access 2003.

Can you tell me what I need to do to make this work?

Many thanks,

David

This has nothing to do with Formatting.
Code the Combo Box AfterUpdate event:
Me![CheckBoxName].Enabled = Me![ComboName] = "Approved"

Place the same code in the form's Current event.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top