VBA in query criteria

elfranzen

Registered User.
Local time
Today, 10:09
Joined
Jul 26, 2007
Messages
93
OK I have worked in Access for awhile now but never worked with SQL statements or anything like that. This is what I am trying to do I want a criteria in a query come from a public string that I have. When some one logs in to the database it stores what property they work for I only want records to show up for that property. I don’t want them to have to type in there property code again every time the query is run. What do I need to do to get this to work? Any help would be greatly appreciated. Thanks

I did post this in the Query section also but I didn't know if it would get a better answer here.
 
You have the criteria in a VBA variable? You can use it, but you can't reference a variable directly. You have to create a public function that returns the value of the variable, and call that in the query criteria.
 
You have the criteria in a VBA variable? You can use it, but you can't reference a variable directly. You have to create a public function that returns the value of the variable, and call that in the query criteria.

Ok I have the property name stored in "Public propertyname As String" how would I get that information into the query to use.
 
Are you having trouble with one of these steps?

You have to create a public function that returns the value of the variable, and call that in the query criteria.
 
Code:
Public Function fPropertyName() As String
fPropertyName = "Value"
End Function
Call fPropertyName() from your query
 
Hello,

I am using a function like the last post and work perfectly. But if I want write a criteria with OR statment in this function, to do anything like this "Value" Or "Value2" in query criteria... Where are a way to do this?

Thank you.
 

Users who are viewing this thread

Back
Top Bottom