Deny Null Entries on a date field

K

Klatuu

You can use either the Form Before Update event or the control's Before
Update event, depending on how you want your form to operate:

Private Sub txtSomeDate_BeForeUpdate(Cancel As Integer)

If IsNull(Me.txtSomeDate) Then
Cancel = True
MsgBox "SomeDate Cannot be Null"
End If
 
J

Jeff Boyce

You could put a value in the Default property (e.g., Date()).

You could add a validation rule to the underlying table's field (Is Not
Null).

You could set the Allow Nulls property of the underlying field to No.

You could add a validation check into the form's BeforeUpdate event
(If Nz(Me!txtYourDate,"") = "" Then
Cancel = True
Msgbox "You must enter a date"
Me!txtYourDate.SetFocus
...)

--
Regards

Jeff Boyce
www.InformationFutures.net

Microsoft Office/Access MVP


Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/

Blade370 said:
Is there a way to stop null entries being entered into a form on a date
field?
 
B

Blade370

Hi,

I put this code into the beforeupdate event but I can still tab to the next
part of the form. It is only when I try to submit the form I get an error
message saying "You cannot go to the specified record." Any ideas???
 
B

Blade370

Hi,
I entered this code but I can still tab to the next field without error. It
is only when trying to submit the form I get the error "You can't go to the
specified record." Anyideas what I am doing wrong?
 
Top