Query criteria from public function results
Posted on 2010-08-17
I am trying to take the results of my function and use it as the criteria for a query, but i'm having no luck. I'm thinking there's a problem with the data type, as this function results in a string, while the field that i'm using this result for is numeric. If I show a msgbox with Allowed(), I get '1 or 2 or 3' which would work fine if i typed that into the query criteria, but using 'Allowed()' as the query criteria gives me no records. Please help.
Here's the function:
Public Function Allowed()
Dim qdf As QueryDef
Dim rst As DAO.Recordset
Set qdf = CurrentDb.QueryDefs!CoStaffQuery
Set rst = qdf.OpenRecordset
Do Until rst.EOF
allowed1 = allowed1 & rst("companyid") & " or "
Allowed = Left(allowed1, Len(allowed1) - 4)