Originally Posted by
Micron
I think you are referring to a vba constructed sql statement, not a stored query, which I (and I think the OP) was dealing with. I say that because of "Query = qryAvailability" in the first post, and the question about a parameter query. I can't see how this would work in a query but I've never tried.
I was referring to both ...BUT ....
As previously mentioned, I use variables to get various columns from both listboxes & comboboxes
Sometimes I assign these to functions but not always
For example in the following VBA SQL statements, I use both the variable & a function based on that variable
The number variable intFileID was column(1) of a combo
Code:
CurrentDb.Execute "UPDATE tblJSONStructure SET tblJSONStructure.SubArrayName = '', tblJSONStructure.TableName = '" & strTableName & "'" & _
" WHERE (((tblJSONStructure.FileID)= " & intFileID & "));"
CurrentDb.Execute "DELETE tblJSONSubArrays.*, tblJSONSubArrays.FileID" & _
" FROM tblJSONSubArrays WHERE (((tblJSONSubArrays.FileID)=GetFileID()));"
Code:
Function GetFileID()
GetFileID = intFileID
End Function
I have found plenty of examples of queries using one or more functions as criteria (including those based on combo column data). For example from the same section of that database:
However, so far I can't find one where I've used the variable itself in the query criteria ... so perhaps my memory is playing me tricks
Indeed I just tested replacing criteria containing a function with the source variable & it failed.
If I do find one with that working I will post it later