S
Steve
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
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