J
James D.
I can't seem to get this to work and am getting a bit frustrated. I have a
query that calls a function in the criteria field(See below for Query syntax).
The functions job is to read in from a different table, take each value read
and append it to a string variable, and return that variable to the query to
be used with the "IN" keyword.
Can I even do this? I have done this with the "Like" command but I cant
seem to get this to work using "In". Any Ideas would be greatly
appreciated.
Every time I run it I get 0 Records, when I should be getting over 40.
Attached is my code for the function and the query:
Query:
SELECT TblSpecType.SpecName, TblSpecType.SpecDescription
FROM TblSpecType
WHERE (((TblSpecType.SpecName) In (GetRespSpec())));
I have the followign Function GetRespSpec() which is designed to read in
from a table, and create a long concat string variable to be used in the "In"
comand.
Function GetRespSpec()
Dim sValue, sHolder, qry As String
Dim rst As Recordset
Dim db As Database
Set db = CurrentDb()
qry = "SELECT [RespDesc] FROM tblRespDesc"
Set rst = db.OpenRecordset(qry)
With rst
.MoveFirst
While Not .EOF
sHolder = ![RespDesc]
sValue = sValue + "'" + sHolder + "',"
.MoveNext
Wend
sValue = sValue + "blueprint"
End With
GetRespSpec = "'sValue'"
rst.Close
End Function
query that calls a function in the criteria field(See below for Query syntax).
The functions job is to read in from a different table, take each value read
and append it to a string variable, and return that variable to the query to
be used with the "IN" keyword.
Can I even do this? I have done this with the "Like" command but I cant
seem to get this to work using "In". Any Ideas would be greatly
appreciated.
Every time I run it I get 0 Records, when I should be getting over 40.
Attached is my code for the function and the query:
Query:
SELECT TblSpecType.SpecName, TblSpecType.SpecDescription
FROM TblSpecType
WHERE (((TblSpecType.SpecName) In (GetRespSpec())));
I have the followign Function GetRespSpec() which is designed to read in
from a table, and create a long concat string variable to be used in the "In"
comand.
Function GetRespSpec()
Dim sValue, sHolder, qry As String
Dim rst As Recordset
Dim db As Database
Set db = CurrentDb()
qry = "SELECT [RespDesc] FROM tblRespDesc"
Set rst = db.OpenRecordset(qry)
With rst
.MoveFirst
While Not .EOF
sHolder = ![RespDesc]
sValue = sValue + "'" + sHolder + "',"
.MoveNext
Wend
sValue = sValue + "blueprint"
End With
GetRespSpec = "'sValue'"
rst.Close
End Function