USERFORM when checkbox is ticked then textbox will display

PLwolves87

New Member
Joined
Jan 6, 2023
Messages
31
Office Version
  1. 365
Platform
  1. Windows
Hi I have some textboxes and checkboxes, basically when i tick the checkbox i want the data to go to a textbox.

here is the code but i get an error please help.


'when ticked the data shall read QUARTER in textbox38, then textbox34 will display the information from combobox4,textbox19,combobox6 & textbox 38 IF NOT TICKED then textbox34 is left blank


Private Sub CheckBox3_Click()
TextBox38.Text = IIf(CheckBox3.Value, "Quarter", "")
TextBox34.value = "ComboBox4 & " " & Textbox19 & " " & ComboBox6 & " " & TextBox38 "
End Sub
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
And the error is?? Try removing the start and end quotes.
TextBox34 = ComboBox4 & " " & Textbox19 & " " & ComboBox6 & " " & TextBox38

No matter if the checkbox is True, your next line will run anyway. I suppose that's not what you want though.
 
Upvote 0
Try this update to your code & see if does what you want

VBA Code:
Private Sub CheckBox3_Click()
    With CheckBox3
        TextBox38.Text = IIf(.Value, "Quarter", "")
        TextBox34.Value = IIf(.Value, ComboBox4 & " " & TextBox19 & " " & ComboBox6 & " " & TextBox38, "")
    End With
End Sub

Dave
 
Upvote 0
And the error is?? Try removing the start and end quotes.
TextBox34 = ComboBox4 & " " & Textbox19 & " " & ComboBox6 & " " & TextBox38

No matter if the checkbox is True, your next line will run anyway. I suppose that's not what you want though.
No matter if the checkbox is True, your next line will run anyway. I suppose that's not what you want though.

yes thats correct i dont want that to happen.
 
Upvote 0
Then more like this, I think:
VBA Code:
Private Sub CheckBox3_Click()

If CheckBox3 Then
     Textbox38.Text = "Quarter"
     TextBox34 = ComboBox4 & " " & Textbox19 & " " & ComboBox6 & " " & Textbox38
Else
     Textbox38.Text = ""
End If

End Sub
 
Upvote 0
Try this update to your code & see if does what you want

VBA Code:
Private Sub CheckBox3_Click()
    With CheckBox3
        TextBox38.Text = IIf(.Value, "Quarter", "")
        TextBox34.Value = IIf(.Value, ComboBox4 & " " & TextBox19 & " " & ComboBox6 & " " & TextBox38, "")
    End With
End Sub

Dave
Hi Dave,

thank you this worked perfectly!!
 
Upvote 0

Forum statistics

Threads
1,215,140
Messages
6,123,270
Members
449,093
Latest member
Vincent Khandagale

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top