Hi Folks,
I have a function that is giving a Run Time Error 3061 Too Few Parameters.
Following is the Function:
Function Concatenate(pstrSQL As String)
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset(pstrSQL)
Dim strConcat As String 'build return string
With rs
If Not .EOF Then
.MoveFirst
Do While Not .EOF
strConcat = strConcat & _
.Fields(0)
.MoveNext
Loop
End If
.Close
End With
Set rs = Nothing
Set db = Nothing
Concatenate = strConcat
End Function
I am calling the function from the following Query:
SELECT allergentype.Formkey, Concatenate("SELECT [Occupexposurelimits] FROM allergentype WHERE Formkey= " & [allergentype]![Formkey]) AS Allergens
FROM allergentype;
allergentype is a query that follows:
SELECT FMMAST.Formkey, FMITEM.Itemkey, INMOEL.Occupexposurelimits
FROM (FMMAST INNER JOIN FMITEM ON FMMAST.Formkey = FMITEM.Formkey) LEFT JOIN INMOEL ON FMITEM.Itemkey = INMOEL.Itemkey
GROUP BY FMMAST.Formkey, FMITEM.Itemkey, INMOEL.Occupexposurelimits
HAVING (((INMOEL.Occupexposurelimits) Is Not Null));
The error is occuring at the following point in the function:
Set rs = db.OpenRecordset(pstrSQL)
The value of pstrSQL = "SELECT [Occupexposurelimits] FROM allergentype WHERE Formkey= OW10105-R1 "
What is causing this error? What can I do?
Thanks in advance
I have a function that is giving a Run Time Error 3061 Too Few Parameters.
Following is the Function:
Function Concatenate(pstrSQL As String)
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset(pstrSQL)
Dim strConcat As String 'build return string
With rs
If Not .EOF Then
.MoveFirst
Do While Not .EOF
strConcat = strConcat & _
.Fields(0)
.MoveNext
Loop
End If
.Close
End With
Set rs = Nothing
Set db = Nothing
Concatenate = strConcat
End Function
I am calling the function from the following Query:
SELECT allergentype.Formkey, Concatenate("SELECT [Occupexposurelimits] FROM allergentype WHERE Formkey= " & [allergentype]![Formkey]) AS Allergens
FROM allergentype;
allergentype is a query that follows:
SELECT FMMAST.Formkey, FMITEM.Itemkey, INMOEL.Occupexposurelimits
FROM (FMMAST INNER JOIN FMITEM ON FMMAST.Formkey = FMITEM.Formkey) LEFT JOIN INMOEL ON FMITEM.Itemkey = INMOEL.Itemkey
GROUP BY FMMAST.Formkey, FMITEM.Itemkey, INMOEL.Occupexposurelimits
HAVING (((INMOEL.Occupexposurelimits) Is Not Null));
The error is occuring at the following point in the function:
Set rs = db.OpenRecordset(pstrSQL)
The value of pstrSQL = "SELECT [Occupexposurelimits] FROM allergentype WHERE Formkey= OW10105-R1 "
What is causing this error? What can I do?
Thanks in advance