Set Special Effect with Checkbox

  • Thread starter Thread starter John Cello
  • Start date Start date
J

John Cello

Trying to set the SpecialEffect of a label determined by the value of a text
box using this code:

Private Sub ckAccountManagement_AfterUpdate()
If Me!ckAccountManagement = True Then
Me!lblAccountManagement.SpecialEffect = 4
ElseIf Me!ckAccountManagement = False Then
Me!lblAccountManagement.SpecialEffect = 0
End If
End Sub

Any ideas where I'm screwing up?
 
You don't need ElseIf, just an Else:

Private Sub ckAccountManagement_AfterUpdate()

If Me!ckAccountManagement Then
Me!lblAccountManagement.SpecialEffect = 4
Else
Me!lblAccountManagement.SpecialEffect = 0
End If

End Sub

You need to ask the code to test if ckAccountManagement is True (checked).
If it is apply effect 4, else (not true) apply effect 0.

Jamie
 
Your code is currently comparing the value of ckAccountManagement against the
booleans True and False. If you wish to check them against the strings
"True" and "False", these need to enclosed in quotes. e.g.
If Me!ckAccountManagement = "True" Then
Me!lblAccountManagement.SpecialEffect = 4
ElseIf Me!ckAccountManagement = "False" Then
Me!lblAccountManagement.SpecialEffect = 0
End If

Hope This Helps
Gerald Stanley MCSD
 
Trying to set the SpecialEffect of a label determined by the value of a text
box using this code:

Private Sub ckAccountManagement_AfterUpdate()
If Me!ckAccountManagement = True Then
Me!lblAccountManagement.SpecialEffect = 4
ElseIf Me!ckAccountManagement = False Then
Me!lblAccountManagement.SpecialEffect = 0
End If
End Sub

Any ideas where I'm screwing up?

It will work if you have the label BorderStyle set to solid and a
Border width set to 2 points or greater for the Raised value. If you
wish to use code just add those to the If .. then.

Because a check box is either true or false you can shorten your code:

Private Sub ckAccountManagement_AfterUpdate()
If Me!ckAccountManagement = True Then
Me!lblAccountManagement.SpecialEffect = 4
Me!lblAccountManagement.BorderWidth = 2 ' up to 6
Else
Me!lblAccountManagement.SpecialEffect = 0
Me!lblAccountManagement.BorderWidth = 0
End If
End Sub

Place the same code in the Form's current event as well.
 
Your code is currently comparing the value of ckAccountManagement against the
booleans True and False. If you wish to check them against the strings
"True" and "False", these need to enclosed in quotes. e.g.
If Me!ckAccountManagement = "True" Then
Me!lblAccountManagement.SpecialEffect = 4
ElseIf Me!ckAccountManagement = "False" Then
Me!lblAccountManagement.SpecialEffect = 0
End If

Hope This Helps
Gerald Stanley MCSD

Gerald,
The original message's subject line was
'Set Special Effect with Checkbox'
 
Thanks to all for your responses. This is what finally worked:

Private Sub ckAccountManagement_AfterUpdate()
If Me!ckAccountManagement = True Then
Me!lblAccountManagement.SpecialEffect = 4
Else
Me!lblAccountManagement.SpecialEffect = 2
End If
End Sub
 
Back
Top