ThinWhiteDude
Technical User
Hopefully, this is the right forum to post this question to.
With the help of several posts on the forum, I have been able to set a variable as criteria in a select query via a form. I used the visual QBE to create this query, and use a function to pull in the variable for the criteria, so I didn’t write the SQL for it.
Here’s the project background:
I have set up a form for users to click a button to run a report for their department. A variable is set in the click event of each department button to hold the string name of their department(strLocation). I have a function that then sets a (public) variable with this department name. Like this:
From the form:
Here are the functions:
For the Department criteria in the query, I call the GetLoc function.
Everything works just fine. However, I need to be able to allow for all records to be pulled in when they click on the “All Depts” button. So, in effect, no criteria. I am stuck on how to pass that on to the function, or set it in the function if necessary.
So. . .
Using this function, how can I pass the equivalent of no criteria to the query?
As always, any help will be much appreciated
TWD
With the help of several posts on the forum, I have been able to set a variable as criteria in a select query via a form. I used the visual QBE to create this query, and use a function to pull in the variable for the criteria, so I didn’t write the SQL for it.
Here’s the project background:
I have set up a form for users to click a button to run a report for their department. A variable is set in the click event of each department button to hold the string name of their department(strLocation). I have a function that then sets a (public) variable with this department name. Like this:
From the form:
Code:
SetLoc (strLocation)
Here are the functions:
Code:
Function SetLoc(strLocation As String)
If strLocation <> "All Depts" Then
gstrLoc = strLocation
Else
End If
End Function
Code:
Function GetLoc() As String
GetLoc = gstrLoc
End Function
Everything works just fine. However, I need to be able to allow for all records to be pulled in when they click on the “All Depts” button. So, in effect, no criteria. I am stuck on how to pass that on to the function, or set it in the function if necessary.
So. . .
Using this function, how can I pass the equivalent of no criteria to the query?
As always, any help will be much appreciated
TWD