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

VBA/mySQL INSERT INTO error

Status
Not open for further replies.

deesheeha

Programmer
Jul 28, 2006
38
IE
Can any one help me?

Im getting an error in the following line:

CurrentDb.Execute ("INSERT INTO callactions(CallActionID, StoreNo, CallID, User, Queries, Action, AssignedTo, Note) VALUES (" & glo.CallActionID & ", '" & glo.GlobalStoreNo & "', '" & glo.GlobalCallID & "', '" & glo.User & "', '" & ComboQuery & "', '" & ComboAction & "', '" & ComboAssTo & "', '" & txtNote & "') ; ")

The error comes back on the Note/ txtNote entry into the database and i cant figure out why. Heres the error im getting:

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


Cheers
Dee
 
Do a Debug.Print of the SQL statement.

Then run it directly in your db.

It should give you a much better idea.
 
What is the first & symbol for in your VALUES statement?

What about:

CurrentDb.Execute ("INSERT INTO callactions(CallActionID, StoreNo, CallID, User, Queries, Action, AssignedTo, Note) VALUES (glo.CallActionID & "[red]'[/red], '" & glo.GlobalStoreNo & "', '" & glo.GlobalCallID & "', '" & glo.User & "', '" & ComboQuery & "', '" & ComboAction & "', '" & ComboAssTo & "', '" & txtNote & "') ; ")

You were also missing one single quote mark i believe.
 
If by chance the txtNote control contains single quote(s) you may try to replace this:
& "', '" & txtNote & "') ; ")
with this:
& "', '" & Replace(txtNote, [tt]"'", "''"[/tt]) & "') ; ")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I would agree with PHV, at least that it's probably
txtNote's value, that is throwing the syntax off?
PHV is remarking that there may be single quotes in
txtNotes value.
If PHV's suggestion, does not work,
then maybe there's a different "illegal" character,
throwing it off?

...Do a debug.print, on txtNote
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top