| Forum Home | ||||
| Press F1 | ||||
| Thread ID: 120392 | 2011-09-07 01:56:00 | Excel VBA | kbp (7436) | Press F1 |
| Post ID | Timestamp | Content | User | ||
| 1229254 | 2011-09-07 01:56:00 | Hi ya I am not so good at VBA with excel, so can someone help me please. I have two fields a) Customer number (named as txtCust) and b) Account number (named as txtAccount). I want to write code, if anything entered in customer number field, account number should be disabled and vice versa. So only one field to be allowed to enter at one time. |
kbp (7436) | ||
| 1229255 | 2011-09-10 13:54:00 | Before I answer your question, a question from me. Will clearing the textbox re-enable the other textbox? | Bob Phillips (16534) | ||
| 1229256 | 2011-09-10 14:13:00 | I'll take a punt that the answer to my question is yes, so here you go Private Sub txtCustomer_AfterUpdate() With Me If .txtCustomer.Text = "" Then .txtAccount.Enabled = True .txtAccount.BackColor = &H80000005 Else .txtAccount.Enabled = False .txtAccount.BackColor = &H8000000B End If End With End Sub Private Sub txtAccount_AfterUpdate() With Me If .txtAccount.Text = "" Then .txtCustomer.Enabled = False .txtCustomer.BackColor = &H80000005 Else .txtCustomer.Enabled = True .txtCustomer.BackColor = &H8000000B End If End With End Sub |
Bob Phillips (16534) | ||
| 1 | |||||