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!

Syntax Error in INTO STATEMENT.....?????

Status
Not open for further replies.

JZII

Technical User
Jan 26, 2001
37
SE
Where is the problem.....
It´s in swedish.....
-------------------------------

Private Sub cmdCopyPost_Click()

DoCmd.RunSQL ("INSERT INTO Leverantörer-Entreprenörer ([Kategori]" _
& ", [Företag], [Adress], [Postnr/Postort], [Kontaktperson], [Telefon], [Mobil], [Fax], [E-post], [Ansvarig], [Datum], [Info]) " _
& "VALUES " _
& "('" & Me![Kategori] & "', " _
& "'" & Me![Företag] & "', " _
& "'" & Me![Adress] & "', " _
& "'" & Me![Postnr/Postort] & "', " _
& "'', " _
& "'" & Me![Telefon] & "', " _
& "'', " _
& "'" & Me![Fax] & "', " _
& "'', " _
& "'" & Me![Ansvarig] & "', " _
& "#" & Me![Datum] & "#, " _
& "'" & Me![Info] & "');")



Requery
DoCmd.GoToRecord , , acLast


JZII
 
I found that when there's a dash (-) in the tablename, you need to enclose it in brackets, like so:

INSERT INTO [Leverantörer-Entreprenörer]


Good Luck,
Niki --------------------------------------
It's not the monsters under your bed, it is the men next door.
That make you fear, make you cry. Make you cry for the Child.
All the wars are fought amongst those lonely men. Unharmed, unscarred.
 
Sorry.... it still doesn't work... same error mess.

JZII
 
Exactly what error message is that? --------------------------------------
It's not the monsters under your bed, it is the men next door.
That make you fear, make you cry. Make you cry for the Child.
All the wars are fought amongst those lonely men. Unharmed, unscarred.
 
compilation error:
syntax error

-

I think you know what I´m trying to acomplish here...
Is there an other way.... I have been stuck with this bit of code for months now... JZII
 
So you want your string to look like this:

DoCmd.RunSQL ("INSERT INTO Leverantörer-Entreprenörer ([Kategori], [Företag], [Adress], [Postnr/Postort], [Kontaktperson], [Telefon], [Mobil], [Fax], [E-post], [Ansvarig], [Datum], [Info]) VALUES ('" & Me![Kategori] & "', '" & Me![Företag] & "', '" & Me![Adress] & "', '" & Me![Postnr/Postort] & "', '', '" & Me![Telefon] & "', '', '" & Me![Fax] & "', '', '" & Me![Ansvarig] & "', #" & Me![Datum] & "#, '" & Me![Info] & "');")

So I'm assuming the three sets of single quotes ('') are there as blank place-holders, correct?

Well, why don't we just remove them, as it is all you're doing is placein a zero-length string in the field, and unless that's jey to something, let's remove them and see what happens...

DoCmd.RunSQL ("INSERT INTO Leverantörer-Entreprenörer ([Kategori]" _
& ", [Företag], [Adress], [Postnr/Postort], [Telefon], [Fax], [Ansvarig], [Datum], [Info]) " _
& "VALUES " _
& "('" & Me![Kategori] & "', " _
& "'" & Me![Företag] & "', " _
& "'" & Me![Adress] & "', " _
& "'" & Me![Postnr/Postort] & "', " _
& "'" & Me![Telefon] & "', " _
& "'" & Me![Fax] & "', " _
& "'" & Me![Ansvarig] & "', " _
& "#" & Me![Datum] & "#, " _
& "'" & Me![Info] & "');")

Give that a shot Kyle
 
One other suggestion, try removing the brackets...

DoCmd.RunSQL "INSERT INTO Leverantörer-Entreprenörer ([Kategori]" _
& ", [Företag], [Adress], [Postnr/Postort], [Telefon], [Fax], [Ansvarig], [Datum], [Info]) " _
& "VALUES " _
& "('" & Me![Kategori] & "', " _
& "'" & Me![Företag] & "', " _
& "'" & Me![Adress] & "', " _
& "'" & Me![Postnr/Postort] & "', " _
& "'" & Me![Telefon] & "', " _
& "'" & Me![Fax] & "', " _
& "'" & Me![Ansvarig] & "', " _
& "#" & Me![Datum] & "#, " _
& "'" & Me![Info] & "');" Kyle
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top