error 3061 too few parameters expected 3.

Golden

New member
Local time
Today, 06:34
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]));
 
If you use code, it will ask you for params.
If you use a query,it won't ask.

Use a query.
 
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...
 
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

Back
Top Bottom