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

Inserting a date into Access

Status
Not open for further replies.

rickgalty

Programmer
Nov 10, 2005
32
US
Thanks for the help on my previous question, everyone.... now I have another problem. I dumped the bound data fields as advised, and am entering new records using SQL. I can't, however, get it to insert a date.

This...

db.Execute "INSERT INTO Records (EmployeeNo, Training) VALUES ('" & txtEmployee.Text & "', '" & txtCourseID.Text & "')"

Works perfectly. But when I try to add the Date field as well, like this....

db.Execute "INSERT INTO Records (EmployeeNo, Training, Date) VALUES ('" & txtEmployee.Text & "', '" & txtCourseID.Text & "', '" & txtDate.Text & "')"

I get "Run-time error 3134. Syntax error in INSERT INTO Statement"

My assumption (Yeah, I know about assumptions! :) ) is that this is a data type error. The Date field format in the Access database is described as "short Date"

Any advice please?
 
Never mind, stupid mistake..... "Date" is a reserved word.

Richard
 
When you work with dates in a Microsoft Access Database, it is best to delimit the dates with a pound sign.

db.Execute "INSERT INTO Records (EmployeeNo, Training, Date) VALUES ('" & txtEmployee.Text & "', '" & txtCourseID.Text & "', [red]#[/red]" & txtDate.Text & "[red]#[/red])"


-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top