W
Walter Maas
I have entered the following code in the On Exit property of a date
field on my form to warn users that they have to enter a date in the
field and the code also makes the focus to stay on the field until data
has been entered:
Private Sub Date_Event_Exit(Cancel As Integer)
If IsNull([Date Event]) Then
DoCmd.CancelEvent
MsgBox "You must enter the date"
Else
End If
End Sub
This shows a message when the <Date Event> field has not received any
data and the focus will stay in the field until some date has been
entered.
However the message also comes up when I close the form without having
done anything (i.e. I just open the form and close it again). It would
be better if the message only came up when I exit the field (with TAB
or mouse). Also the message comes up several times (also after the form
has closed) and you have to click it away several times. This is
annoying.
The Date Event field in the table is set to Required but this doesn't
help in the form, it will accept an empty field(?)
I have tried the Validation setting Is Not Null, but then the user can
complete the whole record and only then it will say that the date has
to be entered. It would like it to happen when they want to leave the
date field and before they complete all the other fields in the
record.
Can anyone help me?
field on my form to warn users that they have to enter a date in the
field and the code also makes the focus to stay on the field until data
has been entered:
Private Sub Date_Event_Exit(Cancel As Integer)
If IsNull([Date Event]) Then
DoCmd.CancelEvent
MsgBox "You must enter the date"
Else
End If
End Sub
This shows a message when the <Date Event> field has not received any
data and the focus will stay in the field until some date has been
entered.
However the message also comes up when I close the form without having
done anything (i.e. I just open the form and close it again). It would
be better if the message only came up when I exit the field (with TAB
or mouse). Also the message comes up several times (also after the form
has closed) and you have to click it away several times. This is
annoying.
The Date Event field in the table is set to Required but this doesn't
help in the form, it will accept an empty field(?)
I have tried the Validation setting Is Not Null, but then the user can
complete the whole record and only then it will say that the date has
to be entered. It would like it to happen when they want to leave the
date field and before they complete all the other fields in the
record.
Can anyone help me?