I have a form with multiple controls. I would like to force the user to enter the date in the control named [date] first, before they enter any other data. In testing the form, I have noticed that users bypass the date field for some reason. When the form opens, the focus is passed to the date control first but users jump to a control in the middle of the form. I don't think they see the cursor flashing in the date field.
I thought it would be easy to check to see if the field was Null on the lost focus event and then force the focus back to the date field but I can't get the code right. The code runs, but the focus stays on the field the user inadvertently moves to rather than going back to the date field. I also tried a validation rule of "IS not null" and a date validation rule but that doesn't seem to work either.
Here is my code:
Code:
Private Sub date_LostFocus()
'prevents the user from skipping the date when filling in the contribution subform
Do
Dim response As String
If IsNull(Me.date) = True Then
response = MsgBox("you must enter the date first", vbRetryCancel)
If response = vbRetry Then
Me.date.SetFocus
Exit Do
Else
Exit Sub
End If
Else
Exit Do
End If
Loop While IsNull(Me.date) = True
End Sub
Thanks for any help you can give me.