I am continually getting Run-Time error '3061': Too few parameters. Expected 2.
Here is the code:
Function PNPullTogether() As String
Dim strPN As String
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("qryPartNumberWO", dbOpenDynaset)
strPN = ""
If rst.EOF Or rst.BOF Then
Exit Function
Else
rst.MoveFirst
Do Until rst.EOF
If strPN = "" Then
strPN = rst!Prefix & "-" & rs!Body & "-" & rst!Suffix
Else
strPN = strPN & ", " & rst!Prefix & "-" & rst!Body & "-" & rst!Suffix
End If
rst.MoveNext
Loop
End If
PNPullTogether = strPN
End Function
The error appears at the OpenRecordset line. The query that is called out runs fine and is not misspelled. I have tried using this function on both forms and reports, calling it as a default value and as a control source. The query it is calling out is the result of two other queries that both limit the amount of records based on a form. Both of these queries also run fine. I have checked spelling in all of the queries multiple times.
John Green
Here is the code:
Function PNPullTogether() As String
Dim strPN As String
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("qryPartNumberWO", dbOpenDynaset)
strPN = ""
If rst.EOF Or rst.BOF Then
Exit Function
Else
rst.MoveFirst
Do Until rst.EOF
If strPN = "" Then
strPN = rst!Prefix & "-" & rs!Body & "-" & rst!Suffix
Else
strPN = strPN & ", " & rst!Prefix & "-" & rst!Body & "-" & rst!Suffix
End If
rst.MoveNext
Loop
End If
PNPullTogether = strPN
End Function
The error appears at the OpenRecordset line. The query that is called out runs fine and is not misspelled. I have tried using this function on both forms and reports, calling it as a default value and as a control source. The query it is calling out is the result of two other queries that both limit the amount of records based on a form. Both of these queries also run fine. I have checked spelling in all of the queries multiple times.
John Green