Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to deturmine NULL date value 2

Status
Not open for further replies.

Dirtbike

IS-IT--Management
Dec 9, 2002
81
US
I cannot seem to be able to check for non-entry of a date field. I've tried:
is Null
= ""
= "__/__/____"

I have a "mask" to force correct date entry. Any help would be great. As you can tell from my question I don't do alot of coding.

Scott in Charlotte, NC
 
Try the IsNull function, or another alternative:

[tt]if trim$(me!txtDataControl.value & "") = "" then
' control is either Null or "" (empty string)
end if[/tt]

Roy-Vidar
 
I have tried this in two ways, in Access 2003 (I think these will work in earlier versions)

1. Set up a text box on a form like this:

Input mask = 00/00/0000;0;_
Validation rule = Is Not Null
Validation text = Please enter a valid date

When I test this, leaving the field blank displays the error message in 'Validation text'.


2. Via VBA code included in the 'lost focus' event of the control, e.g.

Code:
If IsNull(txtDate1) Then
    MsgBox "The date field cannot be left blank"
    txtDate1.SetFocus
End If

or (if you have a 'save record button' on your form):

Code:
btnSaveRecord_click

'other code as required

If IsNull(txtDate1) Then
    MsgBox "The date field cannot be left blank"
    txtDate1.SetFocus
    Exit Sub
End If

'other code as required

End Sub

Your problem might lie with your input mask - I created the one in my example via the wizard - just to make sure the syntax was the way Access likes it!

I hope this will help.


Bob Stubbs
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top