G
Guest
I have craeted the following module to define a function in order to run in a query. When I run the query I get a runtime error that states data type mismatch
======For DAO uncomment next 4 lines======
'====== comment out ADO below ======
'Dim db As DAO.Databas
'Dim rs As DAO.Recordse
'Set db = CurrentD
'Set rs = db.OpenRecordset(pstrSQL
'======For ADO uncomment next two lines====
'====== comment out DAO above =====
Dim rs As New ADODB.Recordse
rs.Open pstrSQL, CurrentProject.Connection,
adOpenKeyset, adLockOptimisti
Dim strConcat As String 'build return strin
With r
If Not .EOF The
.MoveFirs
Do While Not .EO
strConcat = strConcat &
.Fields(0) & pstrDeli
.MoveNex
Loo
End I
.Clos
End Wit
Set rs = Nothin
'====== uncomment next line for DAO =======
'Set db = Nothin
If Len(strConcat) > 0 The
strConcat = Left(strConcat,
Len(strConcat) - Len(pstrDelim)
End I
Concatenate = strConca
End Functio
What can I do to make this work. I am looking to concatinate multiple records into one.
======For DAO uncomment next 4 lines======
'====== comment out ADO below ======
'Dim db As DAO.Databas
'Dim rs As DAO.Recordse
'Set db = CurrentD
'Set rs = db.OpenRecordset(pstrSQL
'======For ADO uncomment next two lines====
'====== comment out DAO above =====
Dim rs As New ADODB.Recordse
rs.Open pstrSQL, CurrentProject.Connection,
adOpenKeyset, adLockOptimisti
Dim strConcat As String 'build return strin
With r
If Not .EOF The
.MoveFirs
Do While Not .EO
strConcat = strConcat &
.Fields(0) & pstrDeli
.MoveNex
Loo
End I
.Clos
End Wit
Set rs = Nothin
'====== uncomment next line for DAO =======
'Set db = Nothin
If Len(strConcat) > 0 The
strConcat = Left(strConcat,
Len(strConcat) - Len(pstrDelim)
End I
Concatenate = strConca
End Functio
What can I do to make this work. I am looking to concatinate multiple records into one.