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

'Saving' Null Date?

Status
Not open for further replies.

Chrisbi

Technical User
Nov 27, 2002
26
US
I have an unbound form from which data entered by user is saved to various
tables when user clicks on 'save' command buttons. Among the fields are
several date fields that do not have to be entered in all circumstances. I
use an SQL statement & docmd.runsql but if date field remains null, I get an
error about a field not being saved. I tried Nz function but I don't think
this works with dates. Any suggestions on how to avoid error would be
gratefully accepted. Thanks.
 
ok-I can check for 'null' date field but how would write code? (Date fields are among other fields being added)

Right now the sql statement looks something like this:

"INSERT INTO tblTempPlace(npTranID, ......, npOFacOut, ...)SELECT '" ... Nz(me.txtFacOut) & "' AS npOFacOut, '" .....;"
 
Turn the warnings off:

Code:
DoCmd.SetWarnings False
DoCmd.RunSQL sqlString
DoCmd.SetWarnings True

HTH...

Ken S.
 
So what you're saying is just to ignore the error message... fine with me but I just wanted to make sure it wouldn't cause some other sort of problem!
 
I can't say whether saving blank date fields will cause any problems in your database, because I don't know how you are using those fields elsewhere in your app. But in general terms, yes, there are times when it's perfectly appropriate to ignore warnings or trap and throw away error messages.

Ken S.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top