maxx_daddy

Board Regular
Joined
Dec 3, 2010
Messages
74
Hi,
I am a novice and any help would be appreciated (ive been working on this for 2 days)
I have a book that is going to be used to track sales. Currently It works awesome and I have a simple userform that has 4 text boxes and 2 combo boxes.
Also it has 3 command buttons (one to save the data and clear the boxes, and one to save the data and close excel and a cancel button)

I need help construting the "if-and-then" statement to lock the two "save" command buttons. I've tried a ton of things off the threads and I'm either putting it in the wrong place in VBA or I'm just not seeing the method properly. (plus I don't see how I could record this as a macro)
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
textbox 2 just needs input of anysort (customer name)
textbox 3 is programmed to take 4 characters
textbox 4 is programmed to take 5 characters (in the properties)
combobox 1 and 2 are both set by data validation to their source cells
textbox 5 just needs input
textbox 6 is optional no parameters are needed its just for comments if needed

i want the command buttons to be turned off until there is the appropriate data in each field (except tb6)
i'm was thinking that i need to put it in the text box_change for each tb but that hasnt been working for me. Also tried sheet change this book change? Just over my head for now.
 
Upvote 0
The syntax would be

Code:
commandbutton2.Enabled = textbox2.Text <> "" And textbox3.Text <> "" And textbox4.Text <> "" And textbox5.Text <> "" And combobox1.Value <> "" And combobox2.Value <> ""

Where you place this depends on the structure of your code.
 
Upvote 0
Well that sure was the head slap ah ha moment for me.
VOG thank you very much. I had tried that code a bunch of times but your comment :
"Where you place this depends on the structure of your code"
got me thinking straight.
This is solved, I placed this code in each combo box or text box and wallah, problem solved.

Thanks again.

Maxx_daddy

Private Sub TextBox5_Change()
CommandButton2.Enabled = TextBox2.Text <> "" _
And TextBox3.Text <> "" And TextBox4.Text <> "" _
And TextBox5.Text <> "" And ComboBox1.Value <> "" _
And ComboBox2.Value <> ""
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,427
Members
448,961
Latest member
nzskater

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