Login or Sign up Help | Site Map
Connecting Tech Pros Worldwide

Toggle between two checkboxes on a form

Question posted by: zufie (Guest) on July 1st, 2008 06:45 PM
I have two checkboxes on a form, ChckIBCCP and ChckOtherReferral.

Each checkbox highlights its respective textboxes and combo boxes on
the form.

Many of the highlighted textboxes and combo boxes are the same for
either checkbox selected.

Some of the highlighted textboxes and combo boxes differ depending
upon which checkbox is selected.

I am unable to toggle between the two differing effects caused by
clicking each respective checkbox.

For example when I click on the second checkbox, ChckOtherReferral,
the highlighted textboxes and combo boxes associated with clicking on
this checkbox remain highlighted even after I click on the first
checkbox, ChckIBCCP!?

Can you help me?

Here is my code if it helps?

Private Sub ChckIBCCP_Click()
Dim ctl As Control

For Each ctl In Me.Controls
If ctl.Tag = "Shadow1" And ChckIBCCP = True _
And ctl.ControlType = 109 Then
ctl.BackColor = 16777215
ElseIf ctl.Tag = "" And ctl.ControlType _
= acTextBox Then
ctl.BackColor = 65535
End If
If ctl.Tag = "Shadow1" And ChckIBCCP = True _
And ctl.ControlType = 111 Then
ctl.BackColor = 16777215
ElseIf ctl.Tag = "" And ctl.ControlType _
= acComboBox Then
ctl.BackColor = 65535
End If
If ctl.Tag = "Shadow1" And ChckIBCCP = True _
And ctl.ControlType = 106 Then
ctl.SpecialEffect = 4
ElseIf ctl.Tag = "" And ctl.ControlType _
= acCheckBox Then
ctl.SpecialEffect = 1
End If
Next
End Sub


Private Sub ChckOtherReferral_Click()
Dim ctl As Control

For Each ctl In Me.Controls
If ctl.Tag = "Shadow1" And ChckOtherReferral = True _
And ctl.ControlType = 109 Then
ctl.BackColor = 16777215
ElseIf ctl.Tag = "" And ctl.ControlType _
= acTextBox Then
ctl.BackColor = 65535
End If
If ctl.Tag = "Shadow1" And ChckOtherReferral = True _
And ctl.ControlType = 111 Then
ctl.BackColor = 16777215
ElseIf ctl.Tag = "" And ctl.ControlType _
= acComboBox Then
ctl.BackColor = 65535
End If
If ctl.Tag = "Shadow1" And ChckOtherReferral = True _
And ctl.ControlType = 106 Then
ctl.SpecialEffect = 4
ElseIf ctl.Tag = "" And ctl.ControlType _
= acCheckBox Then
ctl.SpecialEffect = 1
End If
Next
End Sub


Thanks!,

John
Would you like to answer this question?
Sign up for a free account, or Login (if you're already a member).
Linq Adams via AccessMonster.com's Avatar
Linq Adams via AccessMonster.com
Guest
n/a Posts
July 2nd, 2008
12:45 AM
#2

Re: Toggle between two checkboxes on a form
I won't even try to wade thru all of your code, but basically, at the
beginning of each of your click events, step thru each of your controls,
regardless of their tag properties, and set them to the un-hilighted colors,
then format according to the checkbox that is True..

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

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Fo...access/200807/1


Carlos Nunes-Ueno's Avatar
Carlos Nunes-Ueno
Guest
n/a Posts
July 2nd, 2008
01:45 AM
#3

Re: Toggle between two checkboxes on a form
As far as I can tell you're doing the same code in both scenarios. The
only difference is that you're testing a different checkbox each time.
And since you just checked that box "True" then your code returns would
return the same result each time.

By the way, is there a reason you don't want to use an option group?
This seems like exactly the kind of scenario that would apply. Instead
of two procedures you could write one like this:

Private Sub optIBCCP_or_Other_AfterUpdate()
Select Case Me.optIBCCP_or_Other
Case 1 'IBCCP
'Dehighlight the "Other" fields
'Highlight the IBCCP fields
Case 2 'Other
'Dehighlight the IBCCP fields
'Highlight the "Other" fields
End Select
End Sub

Hope that helps,

Carlos

zufie <john.marruffo@illinois.govwrote in news:8ac70202-0a94-45cc-a4ea-
Join Bytes!:
Quote:
Originally Posted by
I have two checkboxes on a form, ChckIBCCP and ChckOtherReferral.
>
Each checkbox highlights its respective textboxes and combo boxes on
the form.
>
Many of the highlighted textboxes and combo boxes are the same for
either checkbox selected.
>
Some of the highlighted textboxes and combo boxes differ depending
upon which checkbox is selected.
>
I am unable to toggle between the two differing effects caused by
clicking each respective checkbox.
>
For example when I click on the second checkbox, ChckOtherReferral,
the highlighted textboxes and combo boxes associated with clicking on
this checkbox remain highlighted even after I click on the first
checkbox, ChckIBCCP!?
>
Can you help me?
>
Here is my code if it helps?
>
Private Sub ChckIBCCP_Click()
Dim ctl As Control
>
For Each ctl In Me.Controls
If ctl.Tag = "Shadow1" And ChckIBCCP = True _
And ctl.ControlType = 109 Then
ctl.BackColor = 16777215
ElseIf ctl.Tag = "" And ctl.ControlType _
= acTextBox Then
ctl.BackColor = 65535
End If
If ctl.Tag = "Shadow1" And ChckIBCCP = True _
And ctl.ControlType = 111 Then
ctl.BackColor = 16777215
ElseIf ctl.Tag = "" And ctl.ControlType _
= acComboBox Then
ctl.BackColor = 65535
End If
If ctl.Tag = "Shadow1" And ChckIBCCP = True _
And ctl.ControlType = 106 Then
ctl.SpecialEffect = 4
ElseIf ctl.Tag = "" And ctl.ControlType _
= acCheckBox Then
ctl.SpecialEffect = 1
End If
Next
End Sub
>
>
Private Sub ChckOtherReferral_Click()
Dim ctl As Control
>
For Each ctl In Me.Controls
If ctl.Tag = "Shadow1" And ChckOtherReferral = True _
And ctl.ControlType = 109 Then
ctl.BackColor = 16777215
ElseIf ctl.Tag = "" And ctl.ControlType _
= acTextBox Then
ctl.BackColor = 65535
End If
If ctl.Tag = "Shadow1" And ChckOtherReferral = True _
And ctl.ControlType = 111 Then
ctl.BackColor = 16777215
ElseIf ctl.Tag = "" And ctl.ControlType _
= acComboBox Then
ctl.BackColor = 65535
End If
If ctl.Tag = "Shadow1" And ChckOtherReferral = True _
And ctl.ControlType = 106 Then
ctl.SpecialEffect = 4
ElseIf ctl.Tag = "" And ctl.ControlType _
= acCheckBox Then
ctl.SpecialEffect = 1
End If
Next
End Sub
>
>
Thanks!,
>
John
>



zufie's Avatar
zufie
Guest
n/a Posts
July 8th, 2008
02:25 PM
#4

Re: Toggle between two checkboxes on a form
On Jul 1, 8:40*pm, "Carlos Nunes-Ueno" <sulla...@athotmaildot.com>
wrote:
Quote:
Originally Posted by
As far as I can tell you're doing the same code in both scenarios. *The
only difference is that you're testing a different checkbox each time. *
And since you just checked that box "True" then your code returns would
return the same result each time.
>
By the way, is there a reason you don't want to use an option group? *
This seems like exactly the kind of scenario that would apply. *Instead
of two procedures you could write one like this:
>
Private Sub optIBCCP_or_Other_AfterUpdate()
* * Select Case Me.optIBCCP_or_Other
* * * * Case 1 'IBCCP
* * * * * * 'Dehighlight the "Other" fields
* * * * * * * * 'Highlight the IBCCP fields
* * * * Case 2 'Other
* * * * * * 'Dehighlight the IBCCP fields
* * * * * * * * 'Highlight the "Other" fields
* * End Select
End Sub
>
Hope that helps,
>
Carlos
>
zufie <john.marru...@illinois.govwrote in news:8ac70202-0a94-45cc-a4ea-
2921b46f2...@x35g2000hsb.googlegroups.com:
>
>
>
Quote:
Originally Posted by
I have two checkboxes on a form, ChckIBCCP and ChckOtherReferral.

>
Quote:
Originally Posted by
Each checkbox highlights its respective textboxes and combo boxes on
the form.

>
Quote:
Originally Posted by
Many of the highlighted textboxes and combo boxes are the same for
either checkbox selected.

>
Quote:
Originally Posted by
Some of the highlighted textboxes and combo boxes differ depending
upon which checkbox is selected.

>
Quote:
Originally Posted by
I am unable to toggle between the two differing effects caused by
clicking each respective checkbox.

>
Quote:
Originally Posted by
For example when I click on the second checkbox, ChckOtherReferral,
the highlighted textboxes and combo boxes associated with clicking on
this checkbox remain highlighted even after I click on the first
checkbox, ChckIBCCP!?

>
Quote:
Originally Posted by
Can you help me?

>
Quote:
Originally Posted by
Here is my code if it helps?

>
Quote:
Originally Posted by
Private Sub ChckIBCCP_Click()
Dim ctl As Control

>
Quote:
Originally Posted by
* For Each ctl In Me.Controls
* * If ctl.Tag = "Shadow1" And ChckIBCCP = True _
* * And ctl.ControlType = 109 Then
* * * * ctl.BackColor = 16777215
* * ElseIf ctl.Tag = "" And ctl.ControlType _
* * = acTextBox Then
* * ctl.BackColor = 65535
* * End If
* * If ctl.Tag = "Shadow1" And ChckIBCCP = True _
* * And ctl.ControlType = 111 Then
* * * * ctl.BackColor = 16777215
* * ElseIf ctl.Tag = "" And ctl.ControlType _
* * = acComboBox Then
* * * * ctl.BackColor = 65535
* * End If
* * If ctl.Tag = "Shadow1" And ChckIBCCP = True _
* * And ctl.ControlType = 106 Then
* * * * ctl.SpecialEffect = 4
* * ElseIf ctl.Tag = "" And ctl.ControlType _
* * = acCheckBox Then
* * * * ctl.SpecialEffect = 1
* * End If
* *Next
End Sub

>
Quote:
Originally Posted by
Private Sub ChckOtherReferral_Click()
Dim ctl As Control

>
Quote:
Originally Posted by
* For Each ctl In Me.Controls
* * If ctl.Tag = "Shadow1" And ChckOtherReferral = True _
* * And ctl.ControlType = 109 Then
* * * * ctl.BackColor = 16777215
* * ElseIf ctl.Tag = "" And ctl.ControlType _
* * = acTextBox Then
* * ctl.BackColor = 65535
* * End If
* * If ctl.Tag = "Shadow1" And ChckOtherReferral = True _
* * And ctl.ControlType = 111 Then
* * * * ctl.BackColor = 16777215
* * ElseIf ctl.Tag = "" And ctl.ControlType _
* * = acComboBox Then
* * * * ctl.BackColor = 65535
* * End If
* * If ctl.Tag = "Shadow1" And ChckOtherReferral = True _
* * And ctl.ControlType = 106 Then
* * * * ctl.SpecialEffect = 4
* * ElseIf ctl.Tag = "" And ctl.ControlType _
* * = acCheckBox Then
* * * * ctl.SpecialEffect = 1
* * End If
* *Next
End Sub

>
Quote:
Originally Posted by
Thanks!,

>
Quote:
Originally Posted by
John- Hide quoted text -

>
- Show quoted text -


Thank you! I followed your advice and used an option group!

John

zufie's Avatar
zufie
Guest
n/a Posts
July 8th, 2008
02:35 PM
#5

Re: Toggle between two checkboxes on a form
On Jul 1, 8:40*pm, "Carlos Nunes-Ueno" <sulla...@athotmaildot.com>
wrote:
Quote:
Originally Posted by
As far as I can tell you're doing the same code in both scenarios. *The
only difference is that you're testing a different checkbox each time. *
And since you just checked that box "True" then your code returns would
return the same result each time.
>
By the way, is there a reason you don't want to use an option group? *
This seems like exactly the kind of scenario that would apply. *Instead
of two procedures you could write one like this:
>
Private Sub optIBCCP_or_Other_AfterUpdate()
* * Select Case Me.optIBCCP_or_Other
* * * * Case 1 'IBCCP
* * * * * * 'Dehighlight the "Other" fields
* * * * * * * * 'Highlight the IBCCP fields
* * * * Case 2 'Other
* * * * * * 'Dehighlight the IBCCP fields
* * * * * * * * 'Highlight the "Other" fields
* * End Select
End Sub
>
Hope that helps,
>
Carlos
>
zufie <john.marru...@illinois.govwrote in news:8ac70202-0a94-45cc-a4ea-
2921b46f2...@x35g2000hsb.googlegroups.com:
>
>
>
Quote:
Originally Posted by
I have two checkboxes on a form, ChckIBCCP and ChckOtherReferral.

>
Quote:
Originally Posted by
Each checkbox highlights its respective textboxes and combo boxes on
the form.

>
Quote:
Originally Posted by
Many of the highlighted textboxes and combo boxes are the same for
either checkbox selected.

>
Quote:
Originally Posted by
Some of the highlighted textboxes and combo boxes differ depending
upon which checkbox is selected.

>
Quote:
Originally Posted by
I am unable to toggle between the two differing effects caused by
clicking each respective checkbox.

>
Quote:
Originally Posted by
For example when I click on the second checkbox, ChckOtherReferral,
the highlighted textboxes and combo boxes associated with clicking on
this checkbox remain highlighted even after I click on the first
checkbox, ChckIBCCP!?

>
Quote:
Originally Posted by
Can you help me?

>
Quote:
Originally Posted by
Here is my code if it helps?

>
Quote:
Originally Posted by
Private Sub ChckIBCCP_Click()
Dim ctl As Control

>
Quote:
Originally Posted by
* For Each ctl In Me.Controls
* * If ctl.Tag = "Shadow1" And ChckIBCCP = True _
* * And ctl.ControlType = 109 Then
* * * * ctl.BackColor = 16777215
* * ElseIf ctl.Tag = "" And ctl.ControlType _
* * = acTextBox Then
* * ctl.BackColor = 65535
* * End If
* * If ctl.Tag = "Shadow1" And ChckIBCCP = True _
* * And ctl.ControlType = 111 Then
* * * * ctl.BackColor = 16777215
* * ElseIf ctl.Tag = "" And ctl.ControlType _
* * = acComboBox Then
* * * * ctl.BackColor = 65535
* * End If
* * If ctl.Tag = "Shadow1" And ChckIBCCP = True _
* * And ctl.ControlType = 106 Then
* * * * ctl.SpecialEffect = 4
* * ElseIf ctl.Tag = "" And ctl.ControlType _
* * = acCheckBox Then
* * * * ctl.SpecialEffect = 1
* * End If
* *Next
End Sub

>
Quote:
Originally Posted by
Private Sub ChckOtherReferral_Click()
Dim ctl As Control

>
Quote:
Originally Posted by
* For Each ctl In Me.Controls
* * If ctl.Tag = "Shadow1" And ChckOtherReferral = True _
* * And ctl.ControlType = 109 Then
* * * * ctl.BackColor = 16777215
* * ElseIf ctl.Tag = "" And ctl.ControlType _
* * = acTextBox Then
* * ctl.BackColor = 65535
* * End If
* * If ctl.Tag = "Shadow1" And ChckOtherReferral = True _
* * And ctl.ControlType = 111 Then
* * * * ctl.BackColor = 16777215
* * ElseIf ctl.Tag = "" And ctl.ControlType _
* * = acComboBox Then
* * * * ctl.BackColor = 65535
* * End If
* * If ctl.Tag = "Shadow1" And ChckOtherReferral = True _
* * And ctl.ControlType = 106 Then
* * * * ctl.SpecialEffect = 4
* * ElseIf ctl.Tag = "" And ctl.ControlType _
* * = acCheckBox Then
* * * * ctl.SpecialEffect = 1
* * End If
* *Next
End Sub

>
Quote:
Originally Posted by
Thanks!,

>
Quote:
Originally Posted by
John- Hide quoted text -

>
- Show quoted text -


Thank you! I followed your advice!

John

 
Not the answer you were looking for? Post your question . . .
184,042 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

Latest Articles: Read & Comment
  • Didn't find the answer you were looking for?
    Post Your Question
  • Top Community Contributors