Link to home
Start Free TrialLog in
Avatar of xp310
xp310

asked on

Query: Criteria Row to Equal Value in Text Box

Hello,

On my main form, I currently have 3 subforms.

Subform 1:  Active
Subform 2:  DeActive
Subform 3:  Other

Each subform points to the same data source, but the only thing different in each one is in the criteria row, I have either "Active" or "DeActive" or etc...

This way, each subform will only show a records within a specific status.  Well, I'm a bit annoyed having 3 subforms on this form.  I would imagine, I can avoid all this with my idea.

Is there any way, to put some code into the criteria row - that basically points it to a text box on my form that contains the value.

For example...  My plan is to have 1 subform.  Above that, I want a combo box that contains the 3 values (Active being the default value...)

Then when the subform is generated, in the status column it looks for the value of say, "cboStatus" and puts that value into the criteria row.

Does this make sense?
P.S.  I know how to make the subform refresh, I just need it to know where to find the value for the criteria row...

Thank you in advance.
ASKER CERTIFIED SOLUTION
Avatar of omgang
omgang
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
am I right, one subform, but filtered different on flag?

u could try this

private sub cboStatus_AfterUpdate

    Me.mysubform.Form.Filter = "Status = " & cboStatus
    Me.mysubform.Form.FilterOn = True
end sub


Assuming status is numeric
urm, code supplied is for mainform
if u want button on subform, u simply do this

private sub cboStatus_AfterUpdate

    Me.Filter = "Status = " & me.Parent.cboStatus
    Me.FilterOn = True
end sub


this also assumes the field in the subform is called Status
Avatar of xp310
xp310

ASKER

OM Gang,

Your solution worked perfectly.  Thank you very much for you time.

Jay
You're welcome.  Thank you.

OM Gang