D
Danno
Guest
I have a form that I want to have several labels become not visible when I check a combination of two checkboxes. I haven't used VBA in Access before, so syntax for me is a problem.
I am using Access 2000 and here is the code as I have it:
Private Sub Check1_Click()
If ((Me![Check1].Checked = True) And (Me![Check2].Checked = True)) Then
MsgBox "OK", vbOKOnly
percentA.Visible = True
percentB.Visible = False
percentC.Visible = False
percentD.Visible = False
End If
If ((Me![Check1].Checked = False) And (Me![Check2].Checked = True)) Then
percentA.Visible = False
percentB.Visible = True
percentC.Visible = False
percentD.Visible = False
End If
If ((Me![Check1].Checked = True) And (Me![Check2].Checked = False)) Then
percentA.Visible = False
percentB.Visible = False
percentC.Visible = True
percentD.Visible = False
End If
If ((Me![Check1].Checked = False) And (Me![Check2].Checked = False)) Then
percentA.Visible = False
percentB.Visible = False
percentC.Visible = False
percentD.Visible = True
End If
End Sub
Private Sub Check2_Click()
If (Check1 = True) And (Check2 = True) Then
percentA.Visible = True
percentB.Visible = False
percentC.Visible = False
percentD.Visible = False
End If
If (Check1 = False) And (Check2 = True) Then
percentA.Visible = False
percentB.Visible = True
percentC.Visible = False
percentD.Visible = False
End If
If (Check1 = True) And (Check2 = False) Then
percentA.Visible = False
percentB.Visible = False
percentC.Visible = True
percentD.Visible = False
End If
If (Check1 = False) And (Check2 = False) Then
percentA.Visible = False
percentB.Visible = False
percentC.Visible = False
percentD.Visible = True
End If
End Sub
As you can see, I tried a different syntax for the first checkbox than the second. I get nothing but errors on my expression at this point...help!
Danno
I am using Access 2000 and here is the code as I have it:
Private Sub Check1_Click()
If ((Me![Check1].Checked = True) And (Me![Check2].Checked = True)) Then
MsgBox "OK", vbOKOnly
percentA.Visible = True
percentB.Visible = False
percentC.Visible = False
percentD.Visible = False
End If
If ((Me![Check1].Checked = False) And (Me![Check2].Checked = True)) Then
percentA.Visible = False
percentB.Visible = True
percentC.Visible = False
percentD.Visible = False
End If
If ((Me![Check1].Checked = True) And (Me![Check2].Checked = False)) Then
percentA.Visible = False
percentB.Visible = False
percentC.Visible = True
percentD.Visible = False
End If
If ((Me![Check1].Checked = False) And (Me![Check2].Checked = False)) Then
percentA.Visible = False
percentB.Visible = False
percentC.Visible = False
percentD.Visible = True
End If
End Sub
Private Sub Check2_Click()
If (Check1 = True) And (Check2 = True) Then
percentA.Visible = True
percentB.Visible = False
percentC.Visible = False
percentD.Visible = False
End If
If (Check1 = False) And (Check2 = True) Then
percentA.Visible = False
percentB.Visible = True
percentC.Visible = False
percentD.Visible = False
End If
If (Check1 = True) And (Check2 = False) Then
percentA.Visible = False
percentB.Visible = False
percentC.Visible = True
percentD.Visible = False
End If
If (Check1 = False) And (Check2 = False) Then
percentA.Visible = False
percentB.Visible = False
percentC.Visible = False
percentD.Visible = True
End If
End Sub
As you can see, I tried a different syntax for the first checkbox than the second. I get nothing but errors on my expression at this point...help!
Danno