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

Syntax Error With VBA and Date/Time

Status
Not open for further replies.

pparadis

MIS
Dec 5, 2000
22
0
0
US
Any help would be appreciated. I'm trying to keep a log of activity in a database. I have a text box for users to document their activity and I'm trying to time and date stamp each entry, but I keep getting a syntax error. I'm pretty sure it's something I'm doing wrong with date and time. I'm using the Date() and Time() function to get a long time and short date. Here's some code:

Sql = "Insert into Modifications(Day, Time, Descrip)
Values( '" & Date() & "' , '" & Time() & "' , '" & Me.description & "');"

db.Execute (Sql)

I think I need some #'s but I haven't been able to figure out where.

Thanks.
 
Hi!

Instead of the single quotes around your date and time use the # sign. Alternatively, you can set the default value in the table itself for these two fields to date() and time() so that every time a new record is created the current date and time is entered.

Jeff Bridgham
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top