My Toggle btn code not working?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to code my toggle button so that when I click the button the Font
bolds and takes another color. I found this code on another post. But it
doesn't seem to be working.

Any help would be great! Here is the code.

Private Sub Call_Back_Click()
If Me.CallBackBtn.FontBold = False Then
Me.CallBackBtn.FontBold = True
Me.CallBackBtn.ForeColor = vbRed
Else
Me.CallBackBtn.FontBold = False
Me.CallBackBtn.ForeColor = vbBlack
End If
End Sub

Thanks Dustin
 
The name of the event is Call_Back_Click, but you're referring to
Me.CallBackBtn.

If the name of the button is CallBackBtn, I would expect the event to be
declared as

Private Sub CallBackBtn_Click()

(or are you calling Call Call_Back_Click somewhere?)
 
Thanks that did it. But I had to change my code so it would work the way I
want it. And it is close to what I want but there are a few problems. First,
is that when I click the button to true in one record then I all the Call
Back buttons on the continous subform turn red when they are not even clicked
true. And my other problem is that when I open my form or come out of design
view into form view the button that is clicked true is black when it should
be red and when I click it to false and then back to true then it truns red
again.

All I want is for the font to turn red when I click the button in that
record and stay that way until it is clicked again in the future and turned
back to Black.

Here is the code I am using.
Private Sub CallBackBtn_Click()
If Me.CallBackBtn = True Then
Me.CallBackBtn.FontBold = True
Me.CallBackBtn.ForeColor = vbRed
Else
If Me.CallBackBtn = False Then
Me.CallBackBtn.FontBold = True
Me.CallBackBtn.ForeColor = vbBlack
End If
End If
End Sub

Thanks Dustin
 
Back
Top