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 sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking if a Date field is empty

Status
Not open for further replies.

Nialler

Programmer
Feb 25, 2002
11
IE
Im running code behind a button which updates data from a table. However if it encounters a Null value it gives a null error and stops running. I have tried an if statement which checks if its Null first and if so doesn't run the module but it still gives a null error. I've also tried "" but it gives a type mismatch. Any suggestions how you check if a date field empty the code is below would be greatly appreciated
Dim StartDate As Date

While RequestType <> &quot;&quot;
StartDate = [ReturnsReceiptDate]
If StartDate = &quot;&quot; Then 'Problem is here
'Do Nothing
Else
Call DeltaDays6(StartDate)'Module being called
End If
Day_Since_ProductReturn = DeltaDays6(StartDate)
DoCmd.GoToRecord , , acNext
Wend
 
Are you sure it is a Null or Zero Length field - no spaces coming through? Sandy
 
Yeah I have it in the table as a date/time and its up to the user to enter a date at some stage. But if they don't enter anything its completely empty
 
here's an idea, but it doesn't involve the code at all. Since you are working with a form, go into the field properties and on the tag, put a
not null
and it shouldn't let you do any thing untill you put some thing in there... and if you have it as a date field, it will have to be a valid date.

--Junior Junior1544@yahoo.com
Life is change. To deny change is to deny life.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top