A
alexhatzisavas
Hi all.
I'm calling a Public VBA Function (defined in a VBA module) from the
Criterion field of a Query in order to control the criterion of the query.
I'm having a problem making the VBA Function return an expression (such as:
Like "*") that will enable the Query to return all the values for the field
where the Criterion exists.
That is, i want the VBA function to evaluate to an expression such as " Like
"*" ", that will make the Query return all records.
Here are the specifics:
Suppose the Query field is "Customer".
For field "Customer", i have written the following Criterion:
Filter([Forms]![FormName]![FormControl])
"Filter" is the Public VBA Function.
It accepts [Forms]![FormName]![FormControl] as an argument (this is the
value of a control -FormControl- on Form "FormName").
The query is activated via a CommandButton on Form "FormName".
So, on Form "FormName", the user clicks on the CommandButton that activates
the Query.
Depending on whether the user *has* or *has not* selected a value from the
control "FormControl" (which is a ComboBox), i want to achieve the following
functionality:
Case 1 (this I HAVE accomplished...)
- The user *has* selected a value from the ComboBox control (e.g. "ABC"):
Thus, [Forms]![FormName]![FormControl]="ABC"
In the VBA module, the VBA Function (Filter) becomes: Filter="ABC"
In the Query, the Criterion ( Filter([Forms]![FormName]![FormControl] ) now
equals: "ABC"
Thus, field "Customer" is properly filtered, and only records with "ABC"
appear.
This I HAVE accomplished.
Case 2 (this I HAVE NOT accomplished...)
- The user *has not* selected a value from the control:
Thus, [Forms]![FormName]![FormControl]=""
In the VBA module, the VBA Function (Filter) SHOULD evaluate to something
that enables ALL records of the field with the Criterion to be returned.
So, in the VBA code, i'd be lloking for something like:
Filter=" Like "*" " (this doesn't work of course)
That is, i want to have the VBA function (Filter) return such a value that
the criterion becomes Like "*" and all records appear.
Any help would be greatly appreciated.
Thanks,
Alex
I'm calling a Public VBA Function (defined in a VBA module) from the
Criterion field of a Query in order to control the criterion of the query.
I'm having a problem making the VBA Function return an expression (such as:
Like "*") that will enable the Query to return all the values for the field
where the Criterion exists.
That is, i want the VBA function to evaluate to an expression such as " Like
"*" ", that will make the Query return all records.
Here are the specifics:
Suppose the Query field is "Customer".
For field "Customer", i have written the following Criterion:
Filter([Forms]![FormName]![FormControl])
"Filter" is the Public VBA Function.
It accepts [Forms]![FormName]![FormControl] as an argument (this is the
value of a control -FormControl- on Form "FormName").
The query is activated via a CommandButton on Form "FormName".
So, on Form "FormName", the user clicks on the CommandButton that activates
the Query.
Depending on whether the user *has* or *has not* selected a value from the
control "FormControl" (which is a ComboBox), i want to achieve the following
functionality:
Case 1 (this I HAVE accomplished...)
- The user *has* selected a value from the ComboBox control (e.g. "ABC"):
Thus, [Forms]![FormName]![FormControl]="ABC"
In the VBA module, the VBA Function (Filter) becomes: Filter="ABC"
In the Query, the Criterion ( Filter([Forms]![FormName]![FormControl] ) now
equals: "ABC"
Thus, field "Customer" is properly filtered, and only records with "ABC"
appear.
This I HAVE accomplished.
Case 2 (this I HAVE NOT accomplished...)
- The user *has not* selected a value from the control:
Thus, [Forms]![FormName]![FormControl]=""
In the VBA module, the VBA Function (Filter) SHOULD evaluate to something
that enables ALL records of the field with the Criterion to be returned.
So, in the VBA code, i'd be lloking for something like:
Filter=" Like "*" " (this doesn't work of course)
That is, i want to have the VBA function (Filter) return such a value that
the criterion becomes Like "*" and all records appear.
Any help would be greatly appreciated.
Thanks,
Alex