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!

Insert into table won't work with date field - returns 1899 1

Status
Not open for further replies.

dpav29

Technical User
Aug 3, 2001
155
US
The form is basically a due-date entry form. User enters date received and an unbound text box (DueNext) calculates the date the report is next due (i.e. 3 months later.) I then have an INSERT statement to add the new due date, etc into the table.

Here's the code (on click event of a button):

DoCmd.RunSQL ("INSERT INTO [tblReports](reportNO,VendorID,DueDate) VALUES (" & ReportNo & "," & VendorID & "," & FormatDateTime(DueNext) & ");")

The first two fields are inserted, but the DueDate Field is always inserted as 12/30/1899.

From everything I've read, it seems that means a null value was inserted into that field. . .I can't figure out why! The date shows correctly on the form. I'm thinking it has something to do with the fact that it is an unbound field.

Can anyone help with this??
 
Dates, like strings, have delimiters. Where strings use " or ', Dates use the # sign.

VALUES (" & ReportNo & "," & VendorID & ",#" & FormatDateTime(DueNext) & "#);")



"The Key, The Whole Key, and Nothing But The Key, So Help Me Codd!"
 
Can't believe I overlooked that! You're great. . .thanks a ton for the tip and for the extremely quick response!

Dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top