bdsii
02-01-2010, 07:59 AM
I have a ComboBox called Account01. I have specified in the Properties that the default Text is Select Account. The code below checks to make sure the user has selected something from the ComboBox before it allows the user to proceed to the next field.
The code works if the user has not selected something from the ComboBox but it will not remain in the ComboBox for the user to select. What happens if nothing is selected the message box pops up and then when the user clicks OK on the message box the cursor then advances to the next field instead of remaining in the Account01 field. I have used a SetFocus line in the code to return the cursor to the Account01 field.
I cannot figure out why it is working the way it is. :dunno I tried using a Change event instead of an Exit and that didn't even catch that the ComboBox had not been changed from "Select Account".
Anyone with advice for me ?
Private Sub Account01_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If Account01 = "Select Account" Then
MsgBox ("Please Select Account")
Account01.SetFocus
End If
End Sub
The code works if the user has not selected something from the ComboBox but it will not remain in the ComboBox for the user to select. What happens if nothing is selected the message box pops up and then when the user clicks OK on the message box the cursor then advances to the next field instead of remaining in the Account01 field. I have used a SetFocus line in the code to return the cursor to the Account01 field.
I cannot figure out why it is working the way it is. :dunno I tried using a Change event instead of an Exit and that didn't even catch that the ComboBox had not been changed from "Select Account".
Anyone with advice for me ?
Private Sub Account01_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If Account01 = "Select Account" Then
MsgBox ("Please Select Account")
Account01.SetFocus
End If
End Sub