too few parameters in SQL statement (expected 1)

M

Mark Kubicki

(Please) could someone take a look at this SQL syntax error; I'm sure the
problem is obvious, but I'm not seeing it...
I'm getting the error (3061) "too few parameters; expected 1"
Many Thanks in advance,
Mark

------------------------------------
in the table tbeInstallationNotes
PrintInstallationNote = Yes/No
BaseInstallationNote = ,Yes/No
PrintOrder = Number
InstallationNote = Memo
Type = Text

on the form frmSpec
Type = Text

in the table OptInstallationNotes
Options = Memo
OptionNumber = AutoNumber

on the current form
combobox cmbInstallationNoteTitle is bound to the field OptionNumber in
the table OptInstallationNotes
OptionNumber = AutoNumber

-----------------------------------
Dim sSQL As String
Dim vPrintOrder As Variant
vPrintOrder = DMax("[PrintOrder]", "tbeInstallationNotes", "[Type] = '" &
Forms!frmSpec.Type & "'") + 1

sSQL = "INSERT INTO tbeInstallationNotes (PrintInstallationNote,
BaseInstallationNote, PrintOrder, InstallationNote, Type) " & _
"SELECT True, False, vPrintOrder, Options, '" & Forms!frmSpec.Type &
_
"' from OptInstallationNotes where OptionNumber = " &
[cmbInstallationNoteTitle] & ";"

CurrentDb.Execute (sSQL), dbFailOnError
--------------------------------
sSQL is returned as the string:
"INSERT INTO tbeInstallationNotes (PrintInstallationNote,
BaseInstallationNote, PrintOrder, InstallationNote, Type) SELECT True,
False, vPrintOrder, Options, 'TA' from OptInstallationNotes where
OptionNumber = 2;"
 
T

Tom van Stiphout

On Wed, 15 Jul 2009 08:49:37 -0400, "Mark Kubicki"

Probably has to do with vPrintOrder, which is a variable. Rewrite the
line "sSQL =" using:
"...SELECT True, False, " & vPrintOrder & ",...

-Tom.
Microsoft Access MVP
 
M

Mark Kubicki

that was it... THANKS
-m.


Tom van Stiphout said:
On Wed, 15 Jul 2009 08:49:37 -0400, "Mark Kubicki"

Probably has to do with vPrintOrder, which is a variable. Rewrite the
line "sSQL =" using:
"...SELECT True, False, " & vPrintOrder & ",...

-Tom.
Microsoft Access MVP


(Please) could someone take a look at this SQL syntax error; I'm sure the
problem is obvious, but I'm not seeing it...
I'm getting the error (3061) "too few parameters; expected 1"
Many Thanks in advance,
Mark

------------------------------------
in the table tbeInstallationNotes
PrintInstallationNote = Yes/No
BaseInstallationNote = ,Yes/No
PrintOrder = Number
InstallationNote = Memo
Type = Text

on the form frmSpec
Type = Text

in the table OptInstallationNotes
Options = Memo
OptionNumber = AutoNumber

on the current form
combobox cmbInstallationNoteTitle is bound to the field OptionNumber
in
the table OptInstallationNotes
OptionNumber = AutoNumber

-----------------------------------
Dim sSQL As String
Dim vPrintOrder As Variant
vPrintOrder = DMax("[PrintOrder]", "tbeInstallationNotes", "[Type] = '" &
Forms!frmSpec.Type & "'") + 1

sSQL = "INSERT INTO tbeInstallationNotes (PrintInstallationNote,
BaseInstallationNote, PrintOrder, InstallationNote, Type) " & _
"SELECT True, False, vPrintOrder, Options, '" & Forms!frmSpec.Type
&
_
"' from OptInstallationNotes where OptionNumber = " &
[cmbInstallationNoteTitle] & ";"

CurrentDb.Execute (sSQL), dbFailOnError
--------------------------------
sSQL is returned as the string:
"INSERT INTO tbeInstallationNotes (PrintInstallationNote,
BaseInstallationNote, PrintOrder, InstallationNote, Type) SELECT True,
False, vPrintOrder, Options, 'TA' from OptInstallationNotes where
OptionNumber = 2;"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top