Datavisions:
I feel your pain.
You have probably already tried this, but what I do in situations like this is create a dummy string with literal values, execute it, then create a string variable and use the debug window to help me modify the code that creates the string variable until it matches my literal string.
Also, I would lose the line continuation characters/format until I had it down, and then insert them after everything works.
OK, I mean, instead of:
Code:
db.Execute db.Execute "INSERT into tblAAAccidentTemp(" & "OldAccountNumber, " & "RejectCode)" & " VALUES (" & AN & "," & RC & ");"
I would say:
Code:
db.Execute "INSERT into tblAAAccidentTemp(OldAccountNumber,RejectCode) values ('123456789111','SomeString30CharactersLong')"
or:
Code:
db.Execute "INSERT into tblAAAccidentTemp(OldAccountNumber,RejectCode) values (""123456789111"",""SomeString30CharactersLong"")"
(I'm pretty sure that's how you can force quotes into a string)
Then, when my literal string goes in smoothly:
Code:
Dim str_Test as String
str_Test="INSERT into tblAAAccidentTemp(" & "OldAccountNumber, " & "RejectCode)" & " VALUES (" & AN & "," & RC & ");"
debug.print str_Test
I keep modifying
Code:
str_Test="INSERT into tblAAAccidentTemp(" & "OldAccountNumber, " & "RejectCode)" & " VALUES (" & AN & "," & RC & ");"
until it matches the literal string I used to successfully execute the basic command (db.execute).
When I am confident str_Test will fly, test
just to make sure.
Then I can do my
thing with the exact syntax that I used to create str_Test (or just leave the string variable in and always use
; this will help with future troubleshooting; might want to change the variable name to something more meaningful, like str_DBExecute or something).
When all is said and done, I can go back to the code that creates str_Test and make the lines fit better on the screen with the line contination characters.
That's my two cents' worth. Hope it helps.
-Mike