Change Caption in checkbox

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

Guest

I have a useform with a checkbox routine in it. When the check box is not checked it will read Optional if the checkbox is checked I want to have the caption of the checkbox change to required. This works only after you have it the OK button. I want the caption to change with out hitting the OK button. How do you do this. I have seen this done but I cannot figure it our

TI

Private Sub bOk_Click(
With Me.CheckBox
If Me.CheckBox1.Value = True The
Me.CheckBox1.Caption = "Required
strto = "olrequired
Els
Me.CheckBox1 = Fals
Me.CheckBox1.Caption = "Optional
strto = "
End I
End Wit
MsgBox "" & strto 'for testing purposes onl
End Su
 
Use the click event of the checkbox.

Private Sub CheckBox1_Click()
With Me.CheckBox1
If Me.CheckBox1.Value = True Then
Me.CheckBox1.Caption = "Required"
strto = "olrequired"
Else
Me.CheckBox1 = False
Me.CheckBox1.Caption = "Optional"
strto = ""
End If
End With
MsgBox "" & strto 'for testing purposes only
End Sub

--
Regards,
Tom Ogilvy

Hans said:
I have a useform with a checkbox routine in it. When the check box is not
checked it will read Optional if the checkbox is checked I want to have the
caption of the checkbox change to required. This works only after you have
it the OK button. I want the caption to change with out hitting the OK
button. How do you do this. I have seen this done but I cannot figure it
our.
 
Tom
What is the quickest way to do this when you have 6 checkboxes with out writing six sub routines

----- Tom Ogilvy wrote: ----

Use the click event of the checkbox

Private Sub CheckBox1_Click(
With Me.CheckBox
If Me.CheckBox1.Value = True The
Me.CheckBox1.Caption = "Required
strto = "olrequired
Els
Me.CheckBox1 = Fals
Me.CheckBox1.Caption = "Optional
strto = "
End I
End Wit
MsgBox "" & strto 'for testing purposes onl
End Su

--
Regards
Tom Ogilv

Hans said:
I have a useform with a checkbox routine in it. When the check box is no
checked it will read Optional if the checkbox is checked I want to have th
caption of the checkbox change to required. This works only after you hav
it the OK button. I want the caption to change with out hitting the O
button. How do you do this. I have seen this done but I cannot figure i
our
 
Private Sub Checkbox1_Click()
Dim cbox as MSforms.Checkbox
set cbox = Checkbox1
cbox_click cbox
End sub

Private Sub Checkbox2_Click()
Dim cbox as MSforms.Checkbox
set cbox = Checkbox2
cbox_click cbox
End sub


Sub CBox_Click(cbox as MSforms.CheckBox)
If cbox.Value = True Then
cbox.Caption = "Required"
strto = "olrequired"
Else
cbox.Caption = "Optional"
strto = ""
End If
End With
End Sub
 
Back
Top