assign variable to existing query as parameter and requey subform

Local time
Today, 21:23
Joined
Dec 7, 2009
Messages
9
Hi,

I have a form with a subform on it. The main form has the title and one control (group radio button box) that lets you choose between one of three centre.

The subform lists the members of each centre and the data source is an existing query with member information. The item whose paramater I want to change is the one called "centre" in my query (called "all_members")

I was wondering if there was a way using vba to pass a variable as a parameter to the existing query upon which the subform is based so that when I use me.subform.requery it requeries with the new parameter.

Also how would I clear all parameters from the query using vba so that I can also run it with paramaters as "".

I want to avoid using a drop down or combo box and base the "centre" item in the query on the form control.

Many thanks in advance for your kind assistance.

Regards
P.
 
You can either use the Filter property of the form which is housed in the suform control or build the sql of the record source in code.

Filter way:
Code:
Me.SubformControlName.Form.Filter = "ID = " & variableName
Me.SubformControlName.Form.FilterOn = True
 

Users who are viewing this thread

Back
Top Bottom