Error 3061 - Too Few parameters

detrie

Registered User.
Local time
Today, 09:29
Joined
Feb 9, 2006
Messages
113
Access 2003

This statement works great.
Code:
db.Execute "INSERT INTO TBLFILESTEMP (TextFile) VALUES (""" & Replace$(strDelimiter & vbNewLine & var, """", """""") & """);"

I'd like to include FileID (number Long Integer) and use the value from MyForm RecordID (autonumber)
This gives me a Run-Time error '3061': Too few parameters. Expected 1.
Code:
 db.Execute "INSERT INTO TBLFILESTEMP (TextFile, FileID) VALUES (""" & Replace$(strDelimiter & vbNewLine & var, """", """""") & """, me.RecordID);"
 
Quite often, this highlights a spelling error. Is it possible you have misspelled a variable name?

You should -
-create a string variable MySql and assign your sql string to it
-use a debug.print MySql statement to see what SQL is actually rendered.

My guess is you may have an error in the rendered sql which may indicate there is an issue with your concatenation.
 
SQL can't parse "Me.RecordID." Evaluate that outside the string, which is the difference between . . .
Code:
sql = "SELECT * FROM Table WHERE Field = Me.RecordID"
[COLOR="Green"]' vs[/COLOR]
sql = "SELECT * FROM Table WHERE Field = " & Me.RecordID
. . . see how in the first instance all we pass to SQL is the name of the variable, not its value. In the second case the variable is evaluated and the value is passed to the SQL.
 
RESOLVED: Error 3061 - Too Few parameters

This fixed it...
Code:
db.Execute "INSERT INTO TBLFILESTEMP (TextFile, FileID) VALUES (""" & Replace$(strDelimiter & vbNewLine & var, """", """""") & """, " & me.RecordID & ");"
 

Users who are viewing this thread

Back
Top Bottom