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

Insert Into with table that has an AutoNumber? 1

Status
Not open for further replies.

cariengon

Technical User
Mar 18, 2002
283
US
I'm attempting to create a new record in a table that has an Autonumber field and then several of the fields will remain null.

So far, this is what I have:

SQLStmt = "Insert into [000 Import Date Time Data] ([File Name], [Import Date/Time], [Posted Start Date], [Posted End Date]) Values (strFile, Date(), NULL, NULL)"

DoCmd.RunSQL SQLStmt

It seems to run fine, except it prompts me for the strFile. This has already been defined as a string AND a value has been set to it (I've verified it when stepping through the code -it's the name of the file being imported...)

What am I doing wrong with the syntax that it isn't picking up the strFile value?

Thanks,
Carie
 
SQLStmt = "Insert into [000 Import Date Time Data] ([File Name], [Import Date/Time], [Posted Start Date], [Posted End Date]) Values (" & strFile & ", Date(), NULL, NULL)"
-- Just trying to help...
[wolf]<--- This is a wolf? We need a new icon.......
mikewolf@tst-us.com
 
Great! So I got it to recognize the strFile - but now when I run the code, I get a runtime error 3075: Syntax error in query expression.

The data returned is the path and file name of the file being imported. I've checked the field, and it's a text field, set at 255.

Why is this happening now???
 
Never Mind - just found out why... Need to add a single quote around a text field...

'&quot; & strFile & &quot;'

Thanks!
Carie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top