S
Steve
Greetings:
I am attempting to use Duane Hookom's concatenate function (reproduced
below) to concatenate the results of a query named "qryMapMethod". When I
type:
Concatenate("qryMapMethod") into the immediate window I get the following
error:
"Runtime Error 3061. Too few parameters, expected 1" when it attempts to
execute "Set rs = db.OpenRecordset(pstrSQL, dbOpenDynaset)" line of code.
Any help in what I am doing wrong would be greatly appreciated. Thanks.
Steve
Function Concatenate(pstrSQL As String, Optional pstrDelim As String = "; ") _
As String
'Created by Duane Hookom, 2003
'this code may be included in any application/mdb providing
' this statement is left intact
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset(pstrSQL, dbOpenDynaset)
Dim strConcat As String 'build return string
With rs
If Not .EOF Then
.MoveFirst
Do While Not .EOF
strConcat = strConcat & _
.Fields(0) & pstrDelim
.MoveNext
Loop
End If
.Close
End With
Set rs = Nothing
'====== uncomment next line for DAO ========
Set db = Nothing
If Len(strConcat) > 0 Then
strConcat = Left(strConcat, _
Len(strConcat) - Len(pstrDelim))
End If
Concatenate = strConcat
End Function
--
I am attempting to use Duane Hookom's concatenate function (reproduced
below) to concatenate the results of a query named "qryMapMethod". When I
type:
Concatenate("qryMapMethod") into the immediate window I get the following
error:
"Runtime Error 3061. Too few parameters, expected 1" when it attempts to
execute "Set rs = db.OpenRecordset(pstrSQL, dbOpenDynaset)" line of code.
Any help in what I am doing wrong would be greatly appreciated. Thanks.
Steve
Function Concatenate(pstrSQL As String, Optional pstrDelim As String = "; ") _
As String
'Created by Duane Hookom, 2003
'this code may be included in any application/mdb providing
' this statement is left intact
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset(pstrSQL, dbOpenDynaset)
Dim strConcat As String 'build return string
With rs
If Not .EOF Then
.MoveFirst
Do While Not .EOF
strConcat = strConcat & _
.Fields(0) & pstrDelim
.MoveNext
Loop
End If
.Close
End With
Set rs = Nothing
'====== uncomment next line for DAO ========
Set db = Nothing
If Len(strConcat) > 0 Then
strConcat = Left(strConcat, _
Len(strConcat) - Len(pstrDelim))
End If
Concatenate = strConcat
End Function
--