error 3061 too few parameters expected 3. (1 Viewer)

Golden

New member
Local time
Tomorrow, 00:45
Joined
Aug 24, 2020
Messages
1
The following Query is giving me error 3061 too few parameters expected 3. Please help me to solve the problem :
SELECT DISTINCT ExportResults.Numbers, "Dear Parent. " & Left(DLookUp("[Term]","[Terms]","TermID =" & [rTermID]),1) & " " & [rTermID] & " " & ConcatRelated(" Right([Class_Year],2)","[ExportResults]","rPupilID =" & [rPupilID]) & " results for " & ConcatRelated(" [FName]","[Pupil]","PupilID =" & [rPupilID]) & " " & ConcatRelated(" [SName]","[Pupil]","PupilID =" & [rPupilID]) & " " & ConcatRelated("Left([SubjectDiscript],3) & ' '& [tResult]","[ExportResults]","rPupilID =" & [rPupilID]) AS Msg
FROM ExportResults INNER JOIN Pupil ON ExportResults.rPupilID = Pupil.PupilID;


SELECT Results.rPupilID, ParentGuardian.Phone1 AS Numbers, "Dear Parent. " & Left(DLookUp("[Term]","[Terms]","TermID =" & [rTermID]),1) & " " & [rTermID] & " " & Right([Class_Year],2) & " results for " & [FName] & " " & [SName] AS Message, Left([SubjectDiscript],3) & " " & Format([tResult],"#") AS Message2, [FName] & " " & [SName] AS [Names], Results.Class_Year, Results.rClass, Left([rClass],2) AS myClass, Results.rTermID, Subject.SubjectDiscript, Format(100/[TotalMarks]*[MarksScored],"#") AS tResult
FROM Subject RIGHT JOIN ((ParentGuardian RIGHT JOIN Pupil ON ParentGuardian.ParentGdnID = Pupil.ParentID) LEFT JOIN Results ON Pupil.PupilID = Results.rPupilID) ON Subject.SubjectID = Results.rSubjectID
WHERE (((Results.Class_Year)=[Forms]![SelectExptRst]![txtYear]) AND ((Results.rClass)=[Forms]![SelectExptRst]![txtGrade]) AND ((Results.rTermID)=[Forms]![SelectExptRst]![txtTerm]));
 

Ranman256

Well-known member
Local time
Today, 18:45
Joined
Apr 9, 2015
Messages
4,339
If you use code, it will ask you for params.
If you use a query,it won't ask.

Use a query.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 15:45
Joined
Oct 29, 2018
Messages
21,358
Hi. Welcome to AWF!

Both Allen Browne's and my SimpleCSV() functions suffer from this problem when using a parameter query. I do have a Generic Recordset function that handles this error, but you will have to modify Allen's or my function to use it.

Hope that helps...
 

plog

Banishment Pending
Local time
Today, 17:45
Joined
May 11, 2011
Messages
11,612
Code:
...  Left(DLookUp("[Term]","[Terms]","TermID =" & [rTermID]),1) ...

This isn't what you posted about but that one piece of code demonstrates 2 issues:

1. DLookups shouldn't be in queries. If you need data from another table in a query, you JOIN to it and reference it that way.

2. Extracting a portion of a value in a field means you shouldn't be storing all that data in one field. IF the first character of [Term] means something by itself, then it should be stored by itself and not extracted via code when you need it.
 

Users who are viewing this thread

Top Bottom