Filter from Form

D

DDBeards

I have a form that is used to filter data via a query to produce a report.
The form has two control sources, the first is a combo box to select a type
of service and the second is a print all toggle switch. Here is the code I
placed in the Criteria of the querry. The false part of the statement works
great (When the All_Toggle is false), however, when I select the All_Toggle I
get no records at all.

IIf([FORMS]![Frm_RptServ_Filter]![All_Toggle],like
"*",[FORMS]![Frm_RptServ_Filter]![Combo_Serv])

The Criteria is on a text field named X_PID. Please help.

Chris
 
K

KARL DEWEY

Try this --
IIf([FORMS]![Frm_RptServ_Filter]![All_Toggle] = -1,like
"*",[FORMS]![Frm_RptServ_Filter]![Combo_Serv])
 
D

DDBeards

Karl, thanks for the responce, but it did not help. It is if the like "*"
just does not work?

KARL DEWEY said:
Try this --
IIf([FORMS]![Frm_RptServ_Filter]![All_Toggle] = -1,like
"*",[FORMS]![Frm_RptServ_Filter]![Combo_Serv])

--
KARL DEWEY
Build a little - Test a little


DDBeards said:
I have a form that is used to filter data via a query to produce a report.
The form has two control sources, the first is a combo box to select a type
of service and the second is a print all toggle switch. Here is the code I
placed in the Criteria of the querry. The false part of the statement works
great (When the All_Toggle is false), however, when I select the All_Toggle I
get no records at all.

IIf([FORMS]![Frm_RptServ_Filter]![All_Toggle],like
"*",[FORMS]![Frm_RptServ_Filter]![Combo_Serv])

The Criteria is on a text field named X_PID. Please help.

Chris
 
K

KARL DEWEY

Try reversing --
IIf([FORMS]![Frm_RptServ_Filter]![All_Toggle] =
0,[FORMS]![Frm_RptServ_Filter]![Combo_Serv], Like "*")

--
KARL DEWEY
Build a little - Test a little


DDBeards said:
Karl, thanks for the responce, but it did not help. It is if the like "*"
just does not work?

KARL DEWEY said:
Try this --
IIf([FORMS]![Frm_RptServ_Filter]![All_Toggle] = -1,like
"*",[FORMS]![Frm_RptServ_Filter]![Combo_Serv])

--
KARL DEWEY
Build a little - Test a little


DDBeards said:
I have a form that is used to filter data via a query to produce a report.
The form has two control sources, the first is a combo box to select a type
of service and the second is a print all toggle switch. Here is the code I
placed in the Criteria of the querry. The false part of the statement works
great (When the All_Toggle is false), however, when I select the All_Toggle I
get no records at all.

IIf([FORMS]![Frm_RptServ_Filter]![All_Toggle],like
"*",[FORMS]![Frm_RptServ_Filter]![Combo_Serv])

The Criteria is on a text field named X_PID. Please help.

Chris
 
D

DDBeards

Karl, again the it is if the Like "*" just not work in an IIF statement. I
am now playing with the "or" logic and still I can not get around the "*".
Any other ideas?

KARL DEWEY said:
Try reversing --
IIf([FORMS]![Frm_RptServ_Filter]![All_Toggle] =
0,[FORMS]![Frm_RptServ_Filter]![Combo_Serv], Like "*")

--
KARL DEWEY
Build a little - Test a little


DDBeards said:
Karl, thanks for the responce, but it did not help. It is if the like "*"
just does not work?

KARL DEWEY said:
Try this --
IIf([FORMS]![Frm_RptServ_Filter]![All_Toggle] = -1,like
"*",[FORMS]![Frm_RptServ_Filter]![Combo_Serv])

--
KARL DEWEY
Build a little - Test a little


:

I have a form that is used to filter data via a query to produce a report.
The form has two control sources, the first is a combo box to select a type
of service and the second is a print all toggle switch. Here is the code I
placed in the Criteria of the querry. The false part of the statement works
great (When the All_Toggle is false), however, when I select the All_Toggle I
get no records at all.

IIf([FORMS]![Frm_RptServ_Filter]![All_Toggle],like
"*",[FORMS]![Frm_RptServ_Filter]![Combo_Serv])

The Criteria is on a text field named X_PID. Please help.

Chris
 
J

John Spencer

Try the following
Field: X_PID
Criteria: [FORMS]![Frm_RptServ_Filter]![All_Toggle] = True OR
[FORMS]![Frm_RptServ_Filter]![Combo_Serv])


In a Where clause.

WHERE (X_PID = [FORMS]![Frm_RptServ_Filter]![Combo_Serv] OR
[FORMS]![Frm_RptServ_Filter]![All_Toggle] = True)

That should return what you want.

Alternate is to change your combobox so that it has an All option - using a
union query to build the row source.
SELECT WhatEver From Whereever
UNION
SELECT "*" FROM Wherever
ORDER BY Whatever

Then SELECT * when you want all records (being aware that this will still
not get records where the field is NULL)
Field: X_PID
Criteria: Like [FORMS]![Frm_RptServ_Filter]![Combo_Serv])



--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 

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