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

Insert into from form to temp table 1

Status
Not open for further replies.

vburrows

Programmer
May 10, 2005
26
US
I am designing a invoice and I need to send info to a temp table from the different fields on a form I had trouble with the Syntax so I have cut it down to just one fields w which is the description field. and sending it to a like field on the DB.



Sub newtest()
w = Me.DESCR.Value

strSQL = "INSERT INTO las-temp ( DESCR )" & _
"SELECT '" & DESCR & "' AS " & w & ";"

Debug.Print strSQL

DoCmd.RunSQL strSQL

End Sub


Thanks for your help
 
strSQL = "INSERT INTO las-temp (DESCR)" & _
" VALUES ('" & w & "')"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
OK I tried the code you provided (thanks)
and I got and error

"Run-time error '3134':"
"Syntax error in INSERT INTO statement"

What am I doing wrong?
 
I used the code you gave again only I used the immediate window to look at the results is this what it should look like:

INSERT INTO las-temp (DESCR) VALUES ('HAIRCUT')

and yes this is software for a Salon that text value is "haircut"

Thanks again
 
Try this:
strSQL = "INSERT INTO [las-temp] (DESCR)" & _
" VALUES ('" & w & "')"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
You are the wonderful!
this worked
THANKS SOOO Much!
 
What is the syntax when I add the second fields?
 
General syntax:
strSQL = "INSERT INTO [table name] (flield1,field2,field3) VALUES " _
& "('" & someTextVar & "'" _
& ",#" & someDateTimeVar & "#" _
& "," & someNumericVar _
& ")"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top