I am trying to take the results of a subroutine (which is the string strFields in the code below) and pass them to an expression in an Access query. Is this even possible or am I thinking about this the wrong way? Can I only use functions in an expression?
Code:
Sub Fieldnames()
Dim Rst As Recordset
Dim strFields As String
Dim db As Database
Dim f As Field
Dim qdfParmQry As QueryDef
Set db = CurrentDb()
Set qdfParmQry = db.QueryDefs("qry_1test")
qdfParmQry("Forms!Occu_formatting!Species") = [Forms]![Occu_formatting]![Species]
Set Rst = qdfParmQry.OpenRecordset()
For Each f In Rst.Fields
strFields = strFields & f.Name & ", "
Next
Rst.Close
strFields = Left(strFields, Len(strFields) - 2)
End Sub
Comment