Passing Criteria from a Form to underlyng Qry of Report

G

Guest

I have a Form with a combo box on it. That control is used in the criteria
of a Query which feeds a report. When a user selects an item in the combo
box it passes it to the Query and everythign is fine. The syntax I used is
[Forms]![frmCriteriaForTakenNotTakenRpt]![cboCoSA].

Now the problem is if a user doesn't select an item from the combo box I
don't want any criteria to be passed to that field. I attempted this with
the following syntax
IIf(IsNull([Forms]![frmCriteriaForTakenNotTakenRpt]![cboCoSA]),([tblUnitsToCoSA].[strCoSA])
Like "*",[Forms]![frmCriteriaForTakenNotTakenRpt]![cboCoSA]). The problem is
that it won't pass the "Like *" paramater to the field and thus not filter on
that field. Can anyone help me out on this???

Ken T.
 
F

fredg

I have a Form with a combo box on it. That control is used in the criteria
of a Query which feeds a report. When a user selects an item in the combo
box it passes it to the Query and everythign is fine. The syntax I used is
[Forms]![frmCriteriaForTakenNotTakenRpt]![cboCoSA].

Now the problem is if a user doesn't select an item from the combo box I
don't want any criteria to be passed to that field. I attempted this with
the following syntax
IIf(IsNull([Forms]![frmCriteriaForTakenNotTakenRpt]![cboCoSA]),([tblUnitsToCoSA].[strCoSA])
Like "*",[Forms]![frmCriteriaForTakenNotTakenRpt]![cboCoSA]). The problem is
that it won't pass the "Like *" paramater to the field and thus not filter on
that field. Can anyone help me out on this???

Ken T.

Regarding <([tblUnitsToCoSA].[strCoSA]) >
What is this part supposed to do?

The criteria field's datatype is Text?
Change the criteria on the field you are using to:

Like If(IsNull(forms![frmCriteriaForTakenNotTakenRpt]![cboCoSA]),"*",
forms![frmCriteriaForTakenNotTakenRpt]![cboCoSA])

If the combo is null you should get all of the records, otherwise just
the records that equal the combo box bound column.

Your expression would certainly be much easier to comprehend if you
used a shorter form name. I use "ParamForm". It's self-explanatory and
can be taken in at just a glance.
 
G

Guest

fredg...Thanks so very much.

the ([tblUnitsToCoSA].[strCoSA]) portion of the syntax was added
automatically by Access. It points to the table and field where I am
applying the criteria. As you pointed out however in your syntax it is not
needed.

thanks again.



fredg said:
I have a Form with a combo box on it. That control is used in the criteria
of a Query which feeds a report. When a user selects an item in the combo
box it passes it to the Query and everythign is fine. The syntax I used is
[Forms]![frmCriteriaForTakenNotTakenRpt]![cboCoSA].

Now the problem is if a user doesn't select an item from the combo box I
don't want any criteria to be passed to that field. I attempted this with
the following syntax
IIf(IsNull([Forms]![frmCriteriaForTakenNotTakenRpt]![cboCoSA]),([tblUnitsToCoSA].[strCoSA])
Like "*",[Forms]![frmCriteriaForTakenNotTakenRpt]![cboCoSA]). The problem is
that it won't pass the "Like *" paramater to the field and thus not filter on
that field. Can anyone help me out on this???

Ken T.

Regarding <([tblUnitsToCoSA].[strCoSA]) >
What is this part supposed to do?

The criteria field's datatype is Text?
Change the criteria on the field you are using to:

Like If(IsNull(forms![frmCriteriaForTakenNotTakenRpt]![cboCoSA]),"*",
forms![frmCriteriaForTakenNotTakenRpt]![cboCoSA])

If the combo is null you should get all of the records, otherwise just
the records that equal the combo box bound column.

Your expression would certainly be much easier to comprehend if you
used a shorter form name. I use "ParamForm". It's self-explanatory and
can be taken in at just a glance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top