Re: Concatenate results of query
- From: "Carl Rapson" <mr.mxyzptlk@xxxxxxxxxxxxxxxxx>
- Date: Thu, 22 Feb 2007 11:36:21 -0600
Try removing the square brackets "[]" from your Concatenate call:
=Concatenate("qryProc")
Carl Rapson
"Steve" <Steve@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:AEA630C8-A473-4341-9752-D6D8A25ADD22@xxxxxxxxxxxxxxxx
Hi,
I am using Duane Hookom's method for concatenating a string reproduced
below
but I would like to simply pass the name of a query to the function rather
than sending the whole SQL statement. But when I try to do this I get
"Run-time Error 3078 - The Microsoft Jet database engine cannot find the
input table or query '[qryProc]' . Make sure it exists and its name is
spelled correctly". Is it possible to modify how I am using Mr. Hookom's
code
so that I can specify a recordset defined by an existing query by passing
the
query name to the function?
Text box on Form1 Control Source:
=Concatenate("[qryProc]")
qryProc SQL statement:
SELECT tblProcedure.PtDxID, tlkpMasterProcList.Procedure
FROM tblProcedure INNER JOIN tlkpMasterProcList ON tblProcedure.ProcID =
tlkpMasterProcList.ProcID
WHERE (((tblProcedure.PtDxID)=[Forms]![Form1]![PtDxID]));
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)
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
.
- Follow-Ups:
- Re: Concatenate results of query
- From: Steve
- Re: Concatenate results of query
- Prev by Date: Re: Recalculating Subform
- Next by Date: Re: Password login code
- Previous by thread: Subform Issue: Datasheet fields display #Deleted upon subform focus
- Next by thread: Re: Concatenate results of query
- Index(es):
Relevant Pages
|