|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Can anyone see what's wrong with this? (MS Access query)
Hi, I hope this is in the right forum!
I'm trying to do something extremely simple, but I keep getting this error: Runtime error '3134' Syntax error in INSERT INTO statement This is the code it complains about: CurrentDb.Execute "Insert Into Speechfiles(FileName, SpeakerID, SamplingRate, DirectoryPathID, Text, CreationDate, Duration, Range) values (" & Chr(34) & fName & Chr(34) & ", " & spkrID & ", " & rate & ", " & dirPathID & ", " & Chr(34) & txt & Chr(34) & ", " & Chr(34) & crdate & Chr(34) & ", " & duration & ", " & range & ")" Since its so long, I've shown it as multiple lines, but in my code it is one long statement: CurrentDb.Execute "Insert into Speechfiles(...) values (...)" The table is called Speechfiles and the fields are as follows (types are in brackets) FileName (text) SpeakerID (number) SamplingRate (number) DirectoryPathID (number) Text (text) CreationDate (text) <- this isn't date format, so not the prob Duration (number) Range (number) and the values I'm trying to insert are all of the same type as the fields are.... SOOOOOOOOOOOOOooooo, can anyone spot anything? I've spent way to long on this. All my other CurrentDb.Execute "Insert Into...." statements are working fine, it's just this one! Thanks so much in advance... |
|
#2
|
|||
|
|||
|
If anyone's ever interested, the way I fixed this problem was putting [] around the the field names of the table
ex: "Insert Into Speechfiles([FileName], [SpeakerID], ...., [Range]) values (.....)" go figure!! I don't think any of those names are reserved words or anything, so I'm not sure why this fixed the problem, but it is! |
|
#3
|
|||
|
|||
|
You also may want to try executing a string variable rather than typing the SQL query out each time.
I.e. stSQL = "INSERT INTO tblYourTable(etc...." Current.db execute stSQL That way, you should be able to omit the [] around field names. ![]() |
|
#4
|
|||
|
|||
|
try quotes
whereever its text - try single quotes - i've shown for filename:
"Insert Into Speechfiles(FileName, SpeakerID, SamplingRate, DirectoryPathID, Text, CreationDate, Duration, Range) values ( ' " & fName & " ', " & spkrID & ", " & rate & ", " & dirPathID & ", " & Chr(34) & txt & Chr(34) & ", " & Chr(34) & crdate & Chr(34) & ", " & duration & ", " & range & ")" |
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > Can anyone see what's wrong with this? (MS Access query) |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|