When I run the following code the background does not change.
Private Sub Workbook_Open() UserForm1.txtAcctNum.BackColor = vbYellow End Sub
Any ideas? Thanks
When I run the following code the background does not change.
Private Sub Workbook_Open() UserForm1.txtAcctNum.BackColor = vbYellow End Sub
Any ideas? Thanks
Peace of mind is found in some of the strangest places.
That code runs when the workbook opens. It doesn't run when the userform opens. If it affected any userform, it would only be the first time that Userform1 was invoked.
If you want that textbox permanently yellow, you can change the default color of the textbox to yellow in the Property Window. The same place that you changed its name.
Sorry wasnt clear. When you first open the form i want the txtbox yellow. once someone types in it the color needs to go back to white. So where/how would i set that up?
Peace of mind is found in some of the strangest places.
The Form's Initialize sub. It's available from the same VBA Dropdown that all the Controls' Event subs are in.
I expect the student to do their homework and find all the errrors I leeve in.
Please take the time to read the Forum FAQ
I would set the default back color to yellow and then put this code in the userform's code module.i want the txtbox yellow. once someone types in it the color needs to go back to white
Although this might be what you want.Private Sub TextBox1_Change() TextBox.BackColor = vbWhite End Sub
Private Sub TextBox1_Change() With TextBox1 If .Text = vbNullString Then .BackColor = vbYellow Else .BackColor = vbWhite End If End With End Sub
Thanks . This one is Sorted.
Peace of mind is found in some of the strangest places.