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

CheckBox not Active until other CheckBox is checked 2

Status
Not open for further replies.

netrusher

Technical User
Feb 13, 2005
952
US
I have three yes/no checkboxes on a form.

ckbox1
ckbox2
ckbox3

What I want is:

You cannot check ckbox 1 unless ckbox 2 and ckbox 3 are already checked.

How can I do that?

 
In the AfterUpdate event of ckbox1, put

If Me.ckbox2 = false or me.ckbox3 = false then
msgbox "Can't Check this box"
me.ckbox2 =
end if


This keep ckbox2 false unless both of the others are checked first. However, if you try to UNCHECK it, it does the same thing. Without more info, it might not do exactly what you want in other circumstances, but maybe this is enuf for you to fiddle with to get what you want.

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244. Basics at
 
How about:

Me.ckbox1.Enable=(Me.ckbox2 And Me.ckbox3)
 
Howdy netrusher . . .

1st set the Locked property of Checkbox1 to Yes in design view.

Now . . . if your talking a form in Single View thats easy. In the code module of the form copy/paste the following routine:
Code:
[blue]Public Sub chk()
   If Checkbox2 And Checkbox3 Then
      Checkbox1.Enabled = True
   Else
      Checkbox1 = False
      Checkbox1.Enabled = False
   End If
   
End Sub[/blue]
Then in the AfterUpdate event of Checkbox 2&3 and the forms OnLoad event, call the routine:
Code:
[blue]   Call chk[/blue]
For continuous forms you'll have to resort to Conditional Formatting . . .

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
 
When I go to a form I want ckbox1 not enabled until
ckbox2 and ckbox3 are true then when they are true I
want ckbox 1 to be available to ck.
 
You would put the line in the Current Event of the form and the AfterUpdate event of chkbox1.
 
AceMan, Thanks this is single form

What is the code module of the form
 
Remou,

I have the below code in the current event of the form
and the AfterUpdate Event of Checkbox 1. When I check
CheckBox2 & 3 CheckBox1 does not become enabled.

Can you tell me what I am doing wrong?

Code:
Me.RoutingFinance1.Enabled = (Me.FinanceCheckList1_1 And Me.FinanceCheckList1_2)
 
Aceman,

Where do I put the code for a public sub???
 
Sorry, my fault. I should have said the After Update events of both Me.FinanceCheckList1_1 and Me.FinanceCheckList1_2. That is, in the window that opens when you click the three little dots to the right of After Update and select Code Builder.
 
I should add that if the checkboxes are not bound to fields in a table, you will need Nz for nulls:

Code:
Me.RoutingFinance1.Enabled = (Nz(Me.FinanceCheckList1_1,False) And Nz(Me.FinanceCheckList1_2,False)

 
netrusher . . .

Its a little hard to get in posts at work! Just got home.

The code goes in the module behind the form (in form design view, click the [blue]Code[/blue] toolbar button
Code.BMP
.

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top