G Guest Jun 25, 2004 #1 i have a variable declared in a module i want to use it as a criteria in my query how can i incorporate it? help please
i have a variable declared in a module i want to use it as a criteria in my query how can i incorporate it? help please
D Dan Jun 25, 2004 #2 i have a variable declared in a module i want to use it as a criteria in my query how can i incorporate it? help please Click to expand... Let us say your variable is called strCity, that is a string variable. And you want to search on the City field of table tblCities: strSQL = "SELECT * from tblCities WHERE " & strCity & ";"
i have a variable declared in a module i want to use it as a criteria in my query how can i incorporate it? help please Click to expand... Let us say your variable is called strCity, that is a string variable. And you want to search on the City field of table tblCities: strSQL = "SELECT * from tblCities WHERE " & strCity & ";"
G Guest Jun 25, 2004 #3 not in the sql view but in the design view. how can i put it in to the criteria
D Dan Jun 25, 2004 #4 I don't think it is possible to reference a code variable from Query Design Mode...
R Rick Brandt Jun 25, 2004 #5 Dan said: I don't think it is possible to reference a code variable from Query Design Mode... Click to expand... No, but you can use custom functions so all you need is a wrapper function whose only purpose is to return the value of the variable. Function GetStrCity() as String GetStrCity = strCity End Function strSQL = "SELECT * from tblCities WHERE " & GetStrCity() & ";"
Dan said: I don't think it is possible to reference a code variable from Query Design Mode... Click to expand... No, but you can use custom functions so all you need is a wrapper function whose only purpose is to return the value of the variable. Function GetStrCity() as String GetStrCity = strCity End Function strSQL = "SELECT * from tblCities WHERE " & GetStrCity() & ";"