Deny Null Entries on a date field

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a way to stop null entries being entered into a form on a date field?
 
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
 
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?
 
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???
 
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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top