I have a data input form which has an unbound combo box cbCroppingYear. On opening the form the focus is given to the combo box.
The Combo Box is used as a filter so to make sure that the user selects a year I have the following code in the lost focus of the combo box.
If the combo box is empty and the user moves away then the message box shows but on clicking OK the focus moves away from cbCroppingYear. Am I right to use LostFocus and how do I get the focus back to the combo box?
Finally, if the user opens the form in error and then navigates back to the main switchboard by closing the form they get the message box, is there any way around this?
Thanks as always for any suggestions.
The Combo Box is used as a filter so to make sure that the user selects a year I have the following code in the lost focus of the combo box.
Code:
Private Sub cbCroppingYear_LostFocus()
If IsNull(Me!cbCroppingYear) Or Me!cbCroppingYear = "" Then
MsgBox "You must select a cropping year"
Me!cbCroppingYear.SetFocus
End If
End Sub
If the combo box is empty and the user moves away then the message box shows but on clicking OK the focus moves away from cbCroppingYear. Am I right to use LostFocus and how do I get the focus back to the combo box?
Finally, if the user opens the form in error and then navigates back to the main switchboard by closing the form they get the message box, is there any way around this?
Thanks as always for any suggestions.