INSERT INTO

G

Guest

Hi,

I have the following code, I have checked spelling for everything but it
still comes up with "Run-time error: 3061: too few parameters, Expected 1"

Can anyone tell me why!?

CurrentDb.Execute "INSERT INTO exams ( appreceived, datesent, datein,
examcode, examdate, resultsreceived, " & _
"resultssent, confirmation, invoicesent, feepaid, centre, collegeid,
grade, oldstunum ) " & _
"SELECT '" & AppDate & "' AS Expr2, '" & AppDate & "' AS Expr3, '" & AppDate
& "' AS Expr4, " & _
"IIf(" & StrInt & StrExam & "<>'','M2','M3') AS Expr5, " & _
"'" & ExamDate & "' AS Expr1, '" & ResultsDate & "' AS Expr8, '" &
ResultsDate & "' AS Expr9, " & _
"'" & AppDate & "' AS Expr10, '" & AppDate & "' AS Expr11, " & _
"'" & ResultsDate & "' AS Expr12, 1 AS Expr6, 1 AS Expr7,
IIf(([grade]='A'),'Distinction',IIf(([grade]='B'),'Merit'," & _

"IIf(([grade]='C'),'Pass',IIf(([grade]='F'),'Fail',IIf(([grade]='N/C'),'N/C',IIf(([grade]='DNA')," & _
"'DNA',IIf(([grade]='F*'),'Partial',IIf(([grade]='TR'),'DNA',''))))))))
AS Expr13, Westminster.autonum " & _
"FROM Westminster " & _
"WHERE (((Westminster.[Int Oct 97]) Is Not Null) AND (((Westminster.Expiry)
Like '*/05') OR ((Westminster.Expiry) " & _
"Like '*/06') OR ((Westminster.Expiry) Like '*/07') OR
((Westminster.Expiry) Like '*/08') OR ((Westminster.Expiry) " & _
"Like '*/04')) AND (((Westminster.mg)<>'c') And
((Westminster.mg)<>'can') AND ((Westminster.mg)<>'canc'))) OR " & _
"((((Westminster.Expiry) Like '*/05') OR ((Westminster.Expiry) Like
'*/06') OR ((Westminster.Expiry) Like '*/07') OR " & _
"((Westminster.Expiry) Like '*/08') OR ((Westminster.Expiry) Like
'*/04')) AND (((Westminster.mg)<>'c') AND " & _
"((Westminster.mg)<>'can') AND ((Westminster.mg)<>'canc')) AND
(((Westminster.[Adv Oct 97])) Is Not Null));"

CurrentDb.Close

Many thanks. James.
 
O

Ofer

Hi James
Two things to check.

1. it look like you trying to insert date field, in that
case use the # symbol before and after and not a '
unless you use that query in SQL server

2. when you send the query, stop the code, use the debug,
check the sring that been build, its easier to check what
wrong, and that what you should send us to check.

if your parameters doesn't return any value, we can't knew
that

-----Original Message-----
Hi,

I have the following code, I have checked spelling for everything but it
still comes up with "Run-time error: 3061: too few parameters, Expected 1"

Can anyone tell me why!?

CurrentDb.Execute "INSERT INTO exams ( appreceived, datesent, datein,
examcode, examdate, resultsreceived, " & _
"resultssent, confirmation, invoicesent, feepaid, centre, collegeid,
grade, oldstunum ) " & _
"SELECT '" & AppDate & "' AS Expr2, '" & AppDate & "' AS Expr3, '" & AppDate
& "' AS Expr4, " & _
"IIf(" & StrInt & StrExam & "<>'','M2','M3') AS Expr5, " & _
"'" & ExamDate & "' AS Expr1, '" & ResultsDate & "' AS Expr8, '" &
ResultsDate & "' AS Expr9, " & _
"'" & AppDate & "' AS Expr10, '" & AppDate & "' AS Expr11, " & _
"'" & ResultsDate & "' AS Expr12, 1 AS Expr6, 1 AS Expr7,
IIf(([grade]='A'),'Distinction',IIf(([grade] ='B'),'Merit'," & _

"IIf(([grade]='C'),'Pass',IIf(([grade]='F'),'Fail',IIf
(([grade]='N/C'),'N/C',IIf(([grade]='DNA')," & _
"'DNA',IIf(([grade]='F*'),'Partial',IIf(([grade] ='TR'),'DNA',''))))))))
AS Expr13, Westminster.autonum " & _
"FROM Westminster " & _
"WHERE (((Westminster.[Int Oct 97]) Is Not Null) AND (((Westminster.Expiry)
Like '*/05') OR ((Westminster.Expiry) " & _
"Like '*/06') OR ((Westminster.Expiry) Like '*/07') OR
((Westminster.Expiry) Like '*/08') OR ((Westminster.Expiry) " & _
"Like '*/04')) AND (((Westminster.mg)<>'c') And
((Westminster.mg)<>'can') AND ((Westminster.mg)
"((((Westminster.Expiry) Like '*/05') OR ((Westminster.Expiry) Like
'*/06') OR ((Westminster.Expiry) Like '*/07') OR " & _
"((Westminster.Expiry) Like '*/08') OR ((Westminster.Expiry) Like
'*/04')) AND (((Westminster.mg)<>'c') AND " & _
"((Westminster.mg)<>'can') AND ((Westminster.mg)
(((Westminster.[Adv Oct 97])) Is Not Null));"

CurrentDb.Close

Many thanks. James.
.
 
Top