Set Special Effect with Checkbox

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?
 
J

Jamie Richards

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
 
G

Gerald Stanley

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
 
F

fredg

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.
 
F

fredg

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'
 
J

John Cello

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
 

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