Criteria linked to form combo 'Yes/No or All' expression help

E

efandango

I have a query field linked to a form combo box, like this:

Between [Forms]![frm_Runs].[cbo_Point2Point_Getrounds_From] And
[Forms]![frm_Runs].[cbo_Point2Point_Getrounds_To] And
<[Forms]![frm_Runs].[txt_Run_Limit]

In the form combo box I have a -1 or 0 choice. I want a third choice which
is All (or in plain english 'Both'. In other words if the user chooses
All/Both in the combobox, I want the query criteria to show all records.

The format in the combobox can be any format that will get the job done, at
the moment it is plain text. I have tried a Yes/No format but it will not
allow a third state. I want to avoid a checkbox because it is not obvious to
the user that a third state exists with that control.

How can I make the query criteria return All values when the user selects
All/Both instead of either just the -1 or 0s?
 
K

KARL DEWEY

Combo boxes can have multiple columns but only display those you wish. Keep
your -1 and 0 but add a new choice of say three. Use the Column Widths
property to control what is dispalyed like 0"; 1.5" to show the second
column and not the first.

You only posted a part of the SQL statement so I can not advise on how to
edit it for the third choice.
 
E

efandango

Yes, you're correct, I didn't need two combo boxes. I have been using 2
combos for the rest of the form where they were required and just had tunnel
vision regarding this particular combo. No I have a combo that has: Both;-1;0
which works perfectly, except I would prefer somthing more plain english,
like both; Yes; No

But if I use Yes, No, the query doesn't understand it. It seems to only like
the -1;0 criteria. Is their a way of having Yes and No either in the query or
perhaps a mask in the combo box, which I think is what Karl was trying to
explain to me in his reply?

my full SQL is:

SELECT TOP 18 tbl_points.Run_No, tbl_points.Run_Point_Postcode,
tbl_PostCodes.Area, tbl_PostCodes.District, tbl_points.Point_Type,
tbl_points.Getround_Flag, tbl_points.Point_ID, tbl_points.Run_point_Venue,
tbl_points.Run_point_Address
FROM tbl_points LEFT JOIN tbl_PostCodes ON tbl_points.Run_Point_Postcode =
tbl_PostCodes.Postcode
WHERE (((tbl_points.Run_No) Between
[Forms]![frm_Runs].[cbo_Point2Point_From] And
[Forms]![frm_Runs].[cbo_Point2Point_To] And
(tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]="Both",True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Run_Point_Postcode) Between
[Forms]![frm_Runs].[cbo_Point2Point_Postcode_From] And
[Forms]![frm_Runs].[cbo_Point2Point_Postcode_To] And
(tbl_points.Run_Point_Postcode)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]="Both",True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_PostCodes.Area) Between [Forms]![frm_Runs].[cbo_Point2Point_Area_From]
And [Forms]![frm_Runs].[cbo_Point2Point_Area_To] And
(tbl_PostCodes.Area)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]="Both",True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_PostCodes.District) Between
[Forms]![frm_Runs].[cbo_Point2Point_District_From] And
[Forms]![frm_Runs].[cbo_Point2Point_District_To] And
(tbl_PostCodes.District)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]="Both",True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Point_Type) Between
[Forms]![frm_Runs].[cbo_Point2Point_PointType_From] And
[Forms]![frm_Runs].[cbo_Point2Point_PointType_To] And
(tbl_points.Point_Type)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]="Both",True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
ORDER BY Rnd([Point_ID]) DESC;




MGFoster said:
efandango said:
I have a query field linked to a form combo box, like this:

Between [Forms]![frm_Runs].[cbo_Point2Point_Getrounds_From] And
[Forms]![frm_Runs].[cbo_Point2Point_Getrounds_To] And
<[Forms]![frm_Runs].[txt_Run_Limit]

In the form combo box I have a -1 or 0 choice. I want a third choice which
is All (or in plain english 'Both'. In other words if the user chooses
All/Both in the combobox, I want the query criteria to show all records.

The format in the combobox can be any format that will get the job done, at
the moment it is plain text. I have tried a Yes/No format but it will not
allow a third state. I want to avoid a checkbox because it is not obvious to
the user that a third state exists with that control.

How can I make the query criteria return All values when the user selects
All/Both instead of either just the -1 or 0s?

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I don't know why you have 2 ComboBoxes for this requirement - you only
need one.

I'll assume you're using a ValueList for the ComboBoxes' RowSource
properties.... Change them to this: Both, -1, 0

For your 2 ComboBoxes the criteria would be like this:

Between Forms!frm_Runs!cbo_Point2Point_Getrounds_From And
Forms!frm_Runs!cbo_Point2Point_Getrounds_To And
< Forms!frm_Runs!txt_Run_Limit
OR (Forms!frm_Runs!cbo_Point2Point_GetRounds_From = "Both"
OR Forms!frm_Runs!cbo_Point2Point_GetRounds_To = "Both")

If you had just one ComboBox your criteria would be like this:

IIf(Forms!frm_Runs!cbo_Point2Point_GetRounds="Both", True,
Forms!frm_Runs!cbo_Point2Point_GetRounds)

The "True" will cause the query to retury all records (if that is the
only criteria); otherwise the criteria would use -1 or 0, depending on
which one the user selected.

HTH,
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
** Respond only to this newsgroup. I DO NOT respond to emails **

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBSiBolIechKqOuFEgEQIEYgCgmtS/Sl7ClFYinlhTOp6tv4stdIUAnRZz
8n8j/Tjy1oQpnYKJ4joqVAWW
=0oDb
-----END PGP SIGNATURE-----
 
J

John Spencer

If you have one combobox with two columns and its properties set as
--Row source type: Value List
--Column widths: 0
--Row Source: 3;"Both",-1;"True",0;"False"
--Column Count: 2
--Bound Column: 1

You could change the criteria in the query to use this slightly more
complex statement.
tbl_points.Getround_Flag=IIF([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])
and
tbl_points.Getround_Flag=IIF([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,False,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])

MG Foster's proposed solution should work also; but you might run into a
query too complex error with his solution since Access often
significantly restructures the query's where clause using that solution.

'====================================================
John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
'====================================================
Yes, you're correct, I didn't need two combo boxes. I have been using 2
combos for the rest of the form where they were required and just had tunnel
vision regarding this particular combo. No I have a combo that has: Both;-1;0
which works perfectly, except I would prefer somthing more plain english,
like both; Yes; No

But if I use Yes, No, the query doesn't understand it. It seems to only like
the -1;0 criteria. Is their a way of having Yes and No either in the query or
perhaps a mask in the combo box, which I think is what Karl was trying to
explain to me in his reply?

my full SQL is:

SELECT TOP 18 tbl_points.Run_No, tbl_points.Run_Point_Postcode,
tbl_PostCodes.Area, tbl_PostCodes.District, tbl_points.Point_Type,
tbl_points.Getround_Flag, tbl_points.Point_ID, tbl_points.Run_point_Venue,
tbl_points.Run_point_Address
FROM tbl_points LEFT JOIN tbl_PostCodes ON tbl_points.Run_Point_Postcode =
tbl_PostCodes.Postcode
WHERE (((tbl_points.Run_No) Between
[Forms]![frm_Runs].[cbo_Point2Point_From] And
[Forms]![frm_Runs].[cbo_Point2Point_To] And
(tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]="Both",True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Run_Point_Postcode) Between
[Forms]![frm_Runs].[cbo_Point2Point_Postcode_From] And
[Forms]![frm_Runs].[cbo_Point2Point_Postcode_To] And
(tbl_points.Run_Point_Postcode)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]="Both",True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_PostCodes.Area) Between [Forms]![frm_Runs].[cbo_Point2Point_Area_From]
And [Forms]![frm_Runs].[cbo_Point2Point_Area_To] And
(tbl_PostCodes.Area)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]="Both",True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_PostCodes.District) Between
[Forms]![frm_Runs].[cbo_Point2Point_District_From] And
[Forms]![frm_Runs].[cbo_Point2Point_District_To] And
(tbl_PostCodes.District)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]="Both",True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Point_Type) Between
[Forms]![frm_Runs].[cbo_Point2Point_PointType_From] And
[Forms]![frm_Runs].[cbo_Point2Point_PointType_To] And
(tbl_points.Point_Type)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]="Both",True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
ORDER BY Rnd([Point_ID]) DESC;




MGFoster said:
efandango said:
I have a query field linked to a form combo box, like this:

Between [Forms]![frm_Runs].[cbo_Point2Point_Getrounds_From] And
[Forms]![frm_Runs].[cbo_Point2Point_Getrounds_To] And
<[Forms]![frm_Runs].[txt_Run_Limit]

In the form combo box I have a -1 or 0 choice. I want a third choice which
is All (or in plain english 'Both'. In other words if the user chooses
All/Both in the combobox, I want the query criteria to show all records.

The format in the combobox can be any format that will get the job done, at
the moment it is plain text. I have tried a Yes/No format but it will not
allow a third state. I want to avoid a checkbox because it is not obvious to
the user that a third state exists with that control.

How can I make the query criteria return All values when the user selects
All/Both instead of either just the -1 or 0s?
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I don't know why you have 2 ComboBoxes for this requirement - you only
need one.

I'll assume you're using a ValueList for the ComboBoxes' RowSource
properties.... Change them to this: Both, -1, 0

For your 2 ComboBoxes the criteria would be like this:

Between Forms!frm_Runs!cbo_Point2Point_Getrounds_From And
Forms!frm_Runs!cbo_Point2Point_Getrounds_To And
< Forms!frm_Runs!txt_Run_Limit
OR (Forms!frm_Runs!cbo_Point2Point_GetRounds_From = "Both"
OR Forms!frm_Runs!cbo_Point2Point_GetRounds_To = "Both")

If you had just one ComboBox your criteria would be like this:

IIf(Forms!frm_Runs!cbo_Point2Point_GetRounds="Both", True,
Forms!frm_Runs!cbo_Point2Point_GetRounds)

The "True" will cause the query to retury all records (if that is the
only criteria); otherwise the criteria would use -1 or 0, depending on
which one the user selected.

HTH,
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
** Respond only to this newsgroup. I DO NOT respond to emails **

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBSiBolIechKqOuFEgEQIEYgCgmtS/Sl7ClFYinlhTOp6tv4stdIUAnRZz
8n8j/Tjy1oQpnYKJ4joqVAWW
=0oDb
-----END PGP SIGNATURE-----
 
E

efandango

John,

when I try your solution, the query/form fails to return anything when I
select 'both' from the combobox. MG Fosters also fails on the 'both'
criteria, so something must be wrong perhaps somewhere else, or have I got
the syntax wrong somehwere?

here is the line I am pasting into the SQL designer on field: [Getround_Flag]

here is the full SQL:


SELECT TOP 18 tbl_points.Run_No, tbl_points.Run_Point_Postcode,
tbl_PostCodes.Area, tbl_PostCodes.District, tbl_points.Point_Type,
tbl_points.Getround_Flag, tbl_points.Point_ID, tbl_points.Run_point_Venue,
tbl_points.Run_point_Address
FROM tbl_points LEFT JOIN tbl_PostCodes ON tbl_points.Run_Point_Postcode =
tbl_PostCodes.Postcode
WHERE (((tbl_points.Run_No) Between
[Forms]![frm_Runs].[cbo_Point2Point_From] And
[Forms]![frm_Runs].[cbo_Point2Point_To] And
(tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])
And
(tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,False,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Run_Point_Postcode) Between
[Forms]![frm_Runs].[cbo_Point2Point_Postcode_From] And
[Forms]![frm_Runs].[cbo_Point2Point_Postcode_To] And
(tbl_points.Run_Point_Postcode)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])
And
(tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,False,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_PostCodes.Area) Between [Forms]![frm_Runs].[cbo_Point2Point_Area_From]
And [Forms]![frm_Runs].[cbo_Point2Point_Area_To] And
(tbl_PostCodes.Area)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])
And
(tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,False,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_PostCodes.District) Between
[Forms]![frm_Runs].[cbo_Point2Point_District_From] And
[Forms]![frm_Runs].[cbo_Point2Point_District_To] And
(tbl_PostCodes.District)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])
And
(tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,False,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Point_Type) Between
[Forms]![frm_Runs].[cbo_Point2Point_PointType_From] And
[Forms]![frm_Runs].[cbo_Point2Point_PointType_To] And
(tbl_points.Point_Type)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])
And
(tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,False,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
ORDER BY Rnd([Point_ID]) DESC;





John Spencer said:
If you have one combobox with two columns and its properties set as
--Row source type: Value List
--Column widths: 0
--Row Source: 3;"Both",-1;"True",0;"False"
--Column Count: 2
--Bound Column: 1

You could change the criteria in the query to use this slightly more
complex statement.
tbl_points.Getround_Flag=IIF([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])
and
tbl_points.Getround_Flag=IIF([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,False,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])

MG Foster's proposed solution should work also; but you might run into a
query too complex error with his solution since Access often
significantly restructures the query's where clause using that solution.

'====================================================
John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
'====================================================
Yes, you're correct, I didn't need two combo boxes. I have been using 2
combos for the rest of the form where they were required and just had tunnel
vision regarding this particular combo. No I have a combo that has: Both;-1;0
which works perfectly, except I would prefer somthing more plain english,
like both; Yes; No

But if I use Yes, No, the query doesn't understand it. It seems to only like
the -1;0 criteria. Is their a way of having Yes and No either in the query or
perhaps a mask in the combo box, which I think is what Karl was trying to
explain to me in his reply?

my full SQL is:

SELECT TOP 18 tbl_points.Run_No, tbl_points.Run_Point_Postcode,
tbl_PostCodes.Area, tbl_PostCodes.District, tbl_points.Point_Type,
tbl_points.Getround_Flag, tbl_points.Point_ID, tbl_points.Run_point_Venue,
tbl_points.Run_point_Address
FROM tbl_points LEFT JOIN tbl_PostCodes ON tbl_points.Run_Point_Postcode =
tbl_PostCodes.Postcode
WHERE (((tbl_points.Run_No) Between
[Forms]![frm_Runs].[cbo_Point2Point_From] And
[Forms]![frm_Runs].[cbo_Point2Point_To] And
(tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]="Both",True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Run_Point_Postcode) Between
[Forms]![frm_Runs].[cbo_Point2Point_Postcode_From] And
[Forms]![frm_Runs].[cbo_Point2Point_Postcode_To] And
(tbl_points.Run_Point_Postcode)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]="Both",True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_PostCodes.Area) Between [Forms]![frm_Runs].[cbo_Point2Point_Area_From]
And [Forms]![frm_Runs].[cbo_Point2Point_Area_To] And
(tbl_PostCodes.Area)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]="Both",True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_PostCodes.District) Between
[Forms]![frm_Runs].[cbo_Point2Point_District_From] And
[Forms]![frm_Runs].[cbo_Point2Point_District_To] And
(tbl_PostCodes.District)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]="Both",True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Point_Type) Between
[Forms]![frm_Runs].[cbo_Point2Point_PointType_From] And
[Forms]![frm_Runs].[cbo_Point2Point_PointType_To] And
(tbl_points.Point_Type)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]="Both",True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
ORDER BY Rnd([Point_ID]) DESC;




MGFoster said:
efandango wrote:
I have a query field linked to a form combo box, like this:

Between [Forms]![frm_Runs].[cbo_Point2Point_Getrounds_From] And
[Forms]![frm_Runs].[cbo_Point2Point_Getrounds_To] And
<[Forms]![frm_Runs].[txt_Run_Limit]

In the form combo box I have a -1 or 0 choice. I want a third choice which
is All (or in plain english 'Both'. In other words if the user chooses
All/Both in the combobox, I want the query criteria to show all records.

The format in the combobox can be any format that will get the job done, at
the moment it is plain text. I have tried a Yes/No format but it will not
allow a third state. I want to avoid a checkbox because it is not obvious to
the user that a third state exists with that control.

How can I make the query criteria return All values when the user selects
All/Both instead of either just the -1 or 0s?
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I don't know why you have 2 ComboBoxes for this requirement - you only
need one.

I'll assume you're using a ValueList for the ComboBoxes' RowSource
properties.... Change them to this: Both, -1, 0

For your 2 ComboBoxes the criteria would be like this:

Between Forms!frm_Runs!cbo_Point2Point_Getrounds_From And
Forms!frm_Runs!cbo_Point2Point_Getrounds_To And
< Forms!frm_Runs!txt_Run_Limit
OR (Forms!frm_Runs!cbo_Point2Point_GetRounds_From = "Both"
OR Forms!frm_Runs!cbo_Point2Point_GetRounds_To = "Both")

If you had just one ComboBox your criteria would be like this:

IIf(Forms!frm_Runs!cbo_Point2Point_GetRounds="Both", True,
Forms!frm_Runs!cbo_Point2Point_GetRounds)

The "True" will cause the query to retury all records (if that is the
only criteria); otherwise the criteria would use -1 or 0, depending on
which one the user selected.

HTH,
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
** Respond only to this newsgroup. I DO NOT respond to emails **

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBSiBolIechKqOuFEgEQIEYgCgmtS/Sl7ClFYinlhTOp6tv4stdIUAnRZz
8n8j/Tjy1oQpnYKJ4joqVAWW
=0oDb
-----END PGP SIGNATURE-----
 
J

John Spencer MVP

My fault, that should be OR between the two not AND

(tbl_points.Getround_Flag=
IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,True,
[Forms]![frm_Runs]![cbo_Point2Point_GetRounds]
OR
tbl_points.Getround_Flag=
IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,False,
[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])

The logic being that if the combobox returns 3 you will search for the value
being True or False. Otherwise you will search for the value being True or
True; or you will search for the value being False or False.

Again this query could get too complex to run.

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
John,

when I try your solution, the query/form fails to return anything when I
select 'both' from the combobox. MG Fosters also fails on the 'both'
criteria, so something must be wrong perhaps somewhere else, or have I got
the syntax wrong somehwere?

here is the line I am pasting into the SQL designer on field: [Getround_Flag]

here is the full SQL:


SELECT TOP 18 tbl_points.Run_No, tbl_points.Run_Point_Postcode,
tbl_PostCodes.Area, tbl_PostCodes.District, tbl_points.Point_Type,
tbl_points.Getround_Flag, tbl_points.Point_ID, tbl_points.Run_point_Venue,
tbl_points.Run_point_Address
FROM tbl_points LEFT JOIN tbl_PostCodes ON tbl_points.Run_Point_Postcode =
tbl_PostCodes.Postcode
WHERE (((tbl_points.Run_No) Between
[Forms]![frm_Runs].[cbo_Point2Point_From] And
[Forms]![frm_Runs].[cbo_Point2Point_To] And
(tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])
And
(tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,False,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Run_Point_Postcode) Between
[Forms]![frm_Runs].[cbo_Point2Point_Postcode_From] And
[Forms]![frm_Runs].[cbo_Point2Point_Postcode_To] And
(tbl_points.Run_Point_Postcode)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])
And
(tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,False,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_PostCodes.Area) Between [Forms]![frm_Runs].[cbo_Point2Point_Area_From]
And [Forms]![frm_Runs].[cbo_Point2Point_Area_To] And
(tbl_PostCodes.Area)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])
And
(tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,False,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_PostCodes.District) Between
[Forms]![frm_Runs].[cbo_Point2Point_District_From] And
[Forms]![frm_Runs].[cbo_Point2Point_District_To] And
(tbl_PostCodes.District)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])
And
(tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,False,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Point_Type) Between
[Forms]![frm_Runs].[cbo_Point2Point_PointType_From] And
[Forms]![frm_Runs].[cbo_Point2Point_PointType_To] And
(tbl_points.Point_Type)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])
And
(tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,False,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
ORDER BY Rnd([Point_ID]) DESC;





John Spencer said:
If you have one combobox with two columns and its properties set as
--Row source type: Value List
--Column widths: 0
--Row Source: 3;"Both",-1;"True",0;"False"
--Column Count: 2
--Bound Column: 1

You could change the criteria in the query to use this slightly more
complex statement.
tbl_points.Getround_Flag=IIF([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])
and
tbl_points.Getround_Flag=IIF([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,False,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])

MG Foster's proposed solution should work also; but you might run into a
query too complex error with his solution since Access often
significantly restructures the query's where clause using that solution.

'====================================================
John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
'====================================================
Yes, you're correct, I didn't need two combo boxes. I have been using 2
combos for the rest of the form where they were required and just had tunnel
vision regarding this particular combo. No I have a combo that has: Both;-1;0
which works perfectly, except I would prefer somthing more plain english,
like both; Yes; No

But if I use Yes, No, the query doesn't understand it. It seems to only like
the -1;0 criteria. Is their a way of having Yes and No either in the query or
perhaps a mask in the combo box, which I think is what Karl was trying to
explain to me in his reply?

my full SQL is:

SELECT TOP 18 tbl_points.Run_No, tbl_points.Run_Point_Postcode,
tbl_PostCodes.Area, tbl_PostCodes.District, tbl_points.Point_Type,
tbl_points.Getround_Flag, tbl_points.Point_ID, tbl_points.Run_point_Venue,
tbl_points.Run_point_Address
FROM tbl_points LEFT JOIN tbl_PostCodes ON tbl_points.Run_Point_Postcode =
tbl_PostCodes.Postcode
WHERE (((tbl_points.Run_No) Between
[Forms]![frm_Runs].[cbo_Point2Point_From] And
[Forms]![frm_Runs].[cbo_Point2Point_To] And
(tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]="Both",True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Run_Point_Postcode) Between
[Forms]![frm_Runs].[cbo_Point2Point_Postcode_From] And
[Forms]![frm_Runs].[cbo_Point2Point_Postcode_To] And
(tbl_points.Run_Point_Postcode)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]="Both",True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_PostCodes.Area) Between [Forms]![frm_Runs].[cbo_Point2Point_Area_From]
And [Forms]![frm_Runs].[cbo_Point2Point_Area_To] And
(tbl_PostCodes.Area)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]="Both",True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_PostCodes.District) Between
[Forms]![frm_Runs].[cbo_Point2Point_District_From] And
[Forms]![frm_Runs].[cbo_Point2Point_District_To] And
(tbl_PostCodes.District)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]="Both",True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Point_Type) Between
[Forms]![frm_Runs].[cbo_Point2Point_PointType_From] And
[Forms]![frm_Runs].[cbo_Point2Point_PointType_To] And
(tbl_points.Point_Type)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]="Both",True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
ORDER BY Rnd([Point_ID]) DESC;




:

efandango wrote:
I have a query field linked to a form combo box, like this:

Between [Forms]![frm_Runs].[cbo_Point2Point_Getrounds_From] And
[Forms]![frm_Runs].[cbo_Point2Point_Getrounds_To] And
<[Forms]![frm_Runs].[txt_Run_Limit]

In the form combo box I have a -1 or 0 choice. I want a third choice which
is All (or in plain english 'Both'. In other words if the user chooses
All/Both in the combobox, I want the query criteria to show all records.

The format in the combobox can be any format that will get the job done, at
the moment it is plain text. I have tried a Yes/No format but it will not
allow a third state. I want to avoid a checkbox because it is not obvious to
the user that a third state exists with that control.

How can I make the query criteria return All values when the user selects
All/Both instead of either just the -1 or 0s?
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I don't know why you have 2 ComboBoxes for this requirement - you only
need one.

I'll assume you're using a ValueList for the ComboBoxes' RowSource
properties.... Change them to this: Both, -1, 0

For your 2 ComboBoxes the criteria would be like this:

Between Forms!frm_Runs!cbo_Point2Point_Getrounds_From And
Forms!frm_Runs!cbo_Point2Point_Getrounds_To And
< Forms!frm_Runs!txt_Run_Limit
OR (Forms!frm_Runs!cbo_Point2Point_GetRounds_From = "Both"
OR Forms!frm_Runs!cbo_Point2Point_GetRounds_To = "Both")

If you had just one ComboBox your criteria would be like this:

IIf(Forms!frm_Runs!cbo_Point2Point_GetRounds="Both", True,
Forms!frm_Runs!cbo_Point2Point_GetRounds)

The "True" will cause the query to retury all records (if that is the
only criteria); otherwise the criteria would use -1 or 0, depending on
which one the user selected.

HTH,
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
** Respond only to this newsgroup. I DO NOT respond to emails **

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBSiBolIechKqOuFEgEQIEYgCgmtS/Sl7ClFYinlhTOp6tv4stdIUAnRZz
8n8j/Tjy1oQpnYKJ4joqVAWW
=0oDb
-----END PGP SIGNATURE-----
 
E

efandango

John,

I pasted it into the query (see bottom). But it still does a no-show on the
'Both' option, but works on the other two. I accidentally closed the Db, and
reopend it, and immediately got a 'expression is typed incorrectly or too
complex...' error.

So am I stumped, or is there another way of doing it?

my current SQL:

SELECT TOP 18 tbl_points.Run_No, tbl_points.Run_Point_Postcode,
tbl_PostCodes.Area, tbl_PostCodes.District, tbl_points.Point_Type,
tbl_points.Getround_Flag, tbl_points.Point_ID, tbl_points.Run_point_Venue,
tbl_points.Run_point_Address
FROM tbl_points LEFT JOIN tbl_PostCodes ON tbl_points.Run_Point_Postcode =
tbl_PostCodes.Postcode
WHERE (((tbl_points.Run_No) Between
[Forms]![frm_Runs].[cbo_Point2Point_From] And
[Forms]![frm_Runs].[cbo_Point2Point_To] And
(tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])
Or
(tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,False,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Run_Point_Postcode) Between
[Forms]![frm_Runs].[cbo_Point2Point_Postcode_From] And
[Forms]![frm_Runs].[cbo_Point2Point_Postcode_To] And
(tbl_points.Run_Point_Postcode)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])
Or
(tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,False,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_PostCodes.Area) Between [Forms]![frm_Runs].[cbo_Point2Point_Area_From]
And [Forms]![frm_Runs].[cbo_Point2Point_Area_To] And
(tbl_PostCodes.Area)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])
Or
(tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,False,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_PostCodes.District) Between
[Forms]![frm_Runs].[cbo_Point2Point_District_From] And
[Forms]![frm_Runs].[cbo_Point2Point_District_To] And
(tbl_PostCodes.District)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])
Or
(tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,False,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Point_Type) Between
[Forms]![frm_Runs].[cbo_Point2Point_PointType_From] And
[Forms]![frm_Runs].[cbo_Point2Point_PointType_To] And
(tbl_points.Point_Type)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])
Or
(tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,False,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
ORDER BY Rnd([Point_ID]) DESC;


John Spencer MVP said:
My fault, that should be OR between the two not AND

(tbl_points.Getround_Flag=
IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,True,
[Forms]![frm_Runs]![cbo_Point2Point_GetRounds]
OR
tbl_points.Getround_Flag=
IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,False,
[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])

The logic being that if the combobox returns 3 you will search for the value
being True or False. Otherwise you will search for the value being True or
True; or you will search for the value being False or False.

Again this query could get too complex to run.

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
John,

when I try your solution, the query/form fails to return anything when I
select 'both' from the combobox. MG Fosters also fails on the 'both'
criteria, so something must be wrong perhaps somewhere else, or have I got
the syntax wrong somehwere?

here is the line I am pasting into the SQL designer on field: [Getround_Flag]

here is the full SQL:


SELECT TOP 18 tbl_points.Run_No, tbl_points.Run_Point_Postcode,
tbl_PostCodes.Area, tbl_PostCodes.District, tbl_points.Point_Type,
tbl_points.Getround_Flag, tbl_points.Point_ID, tbl_points.Run_point_Venue,
tbl_points.Run_point_Address
FROM tbl_points LEFT JOIN tbl_PostCodes ON tbl_points.Run_Point_Postcode =
tbl_PostCodes.Postcode
WHERE (((tbl_points.Run_No) Between
[Forms]![frm_Runs].[cbo_Point2Point_From] And
[Forms]![frm_Runs].[cbo_Point2Point_To] And
(tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])
And
(tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,False,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Run_Point_Postcode) Between
[Forms]![frm_Runs].[cbo_Point2Point_Postcode_From] And
[Forms]![frm_Runs].[cbo_Point2Point_Postcode_To] And
(tbl_points.Run_Point_Postcode)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])
And
(tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,False,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_PostCodes.Area) Between [Forms]![frm_Runs].[cbo_Point2Point_Area_From]
And [Forms]![frm_Runs].[cbo_Point2Point_Area_To] And
(tbl_PostCodes.Area)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])
And
(tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,False,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_PostCodes.District) Between
[Forms]![frm_Runs].[cbo_Point2Point_District_From] And
[Forms]![frm_Runs].[cbo_Point2Point_District_To] And
(tbl_PostCodes.District)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])
And
(tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,False,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Point_Type) Between
[Forms]![frm_Runs].[cbo_Point2Point_PointType_From] And
[Forms]![frm_Runs].[cbo_Point2Point_PointType_To] And
(tbl_points.Point_Type)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])
And
(tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,False,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
ORDER BY Rnd([Point_ID]) DESC;





John Spencer said:
If you have one combobox with two columns and its properties set as
--Row source type: Value List
--Column widths: 0
--Row Source: 3;"Both",-1;"True",0;"False"
--Column Count: 2
--Bound Column: 1

You could change the criteria in the query to use this slightly more
complex statement.
tbl_points.Getround_Flag=IIF([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])
and
tbl_points.Getround_Flag=IIF([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,False,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])

MG Foster's proposed solution should work also; but you might run into a
query too complex error with his solution since Access often
significantly restructures the query's where clause using that solution.

'====================================================
John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
'====================================================

efandango wrote:
Yes, you're correct, I didn't need two combo boxes. I have been using 2
combos for the rest of the form where they were required and just had tunnel
vision regarding this particular combo. No I have a combo that has: Both;-1;0
which works perfectly, except I would prefer somthing more plain english,
like both; Yes; No

But if I use Yes, No, the query doesn't understand it. It seems to only like
the -1;0 criteria. Is their a way of having Yes and No either in the query or
perhaps a mask in the combo box, which I think is what Karl was trying to
explain to me in his reply?

my full SQL is:

SELECT TOP 18 tbl_points.Run_No, tbl_points.Run_Point_Postcode,
tbl_PostCodes.Area, tbl_PostCodes.District, tbl_points.Point_Type,
tbl_points.Getround_Flag, tbl_points.Point_ID, tbl_points.Run_point_Venue,
tbl_points.Run_point_Address
FROM tbl_points LEFT JOIN tbl_PostCodes ON tbl_points.Run_Point_Postcode =
tbl_PostCodes.Postcode
WHERE (((tbl_points.Run_No) Between
[Forms]![frm_Runs].[cbo_Point2Point_From] And
[Forms]![frm_Runs].[cbo_Point2Point_To] And
(tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]="Both",True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Run_Point_Postcode) Between
[Forms]![frm_Runs].[cbo_Point2Point_Postcode_From] And
[Forms]![frm_Runs].[cbo_Point2Point_Postcode_To] And
(tbl_points.Run_Point_Postcode)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]="Both",True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_PostCodes.Area) Between [Forms]![frm_Runs].[cbo_Point2Point_Area_From]
And [Forms]![frm_Runs].[cbo_Point2Point_Area_To] And
(tbl_PostCodes.Area)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]="Both",True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_PostCodes.District) Between
[Forms]![frm_Runs].[cbo_Point2Point_District_From] And
[Forms]![frm_Runs].[cbo_Point2Point_District_To] And
(tbl_PostCodes.District)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]="Both",True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Point_Type) Between
[Forms]![frm_Runs].[cbo_Point2Point_PointType_From] And
[Forms]![frm_Runs].[cbo_Point2Point_PointType_To] And
(tbl_points.Point_Type)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]="Both",True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
ORDER BY Rnd([Point_ID]) DESC;




:

efandango wrote:
I have a query field linked to a form combo box, like this:

Between [Forms]![frm_Runs].[cbo_Point2Point_Getrounds_From] And
[Forms]![frm_Runs].[cbo_Point2Point_Getrounds_To] And
<[Forms]![frm_Runs].[txt_Run_Limit]

In the form combo box I have a -1 or 0 choice. I want a third choice which
is All (or in plain english 'Both'. In other words if the user chooses
All/Both in the combobox, I want the query criteria to show all records.

The format in the combobox can be any format that will get the job done, at
the moment it is plain text. I have tried a Yes/No format but it will not
allow a third state. I want to avoid a checkbox because it is not obvious to
the user that a third state exists with that control.

How can I make the query criteria return All values when the user selects
All/Both instead of either just the -1 or 0s?
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I don't know why you have 2 ComboBoxes for this requirement - you only
need one.

I'll assume you're using a ValueList for the ComboBoxes' RowSource
properties.... Change them to this: Both, -1, 0

For your 2 ComboBoxes the criteria would be like this:

Between Forms!frm_Runs!cbo_Point2Point_Getrounds_From And
Forms!frm_Runs!cbo_Point2Point_Getrounds_To And
< Forms!frm_Runs!txt_Run_Limit
OR (Forms!frm_Runs!cbo_Point2Point_GetRounds_From = "Both"
OR Forms!frm_Runs!cbo_Point2Point_GetRounds_To = "Both")

If you had just one ComboBox your criteria would be like this:

IIf(Forms!frm_Runs!cbo_Point2Point_GetRounds="Both", True,
Forms!frm_Runs!cbo_Point2Point_GetRounds)

The "True" will cause the query to retury all records (if that is the
only criteria); otherwise the criteria would use -1 or 0, depending on
which one the user selected.

HTH,
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
** Respond only to this newsgroup. I DO NOT respond to emails **

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBSiBolIechKqOuFEgEQIEYgCgmtS/Sl7ClFYinlhTOp6tv4stdIUAnRZz
8n8j/Tjy1oQpnYKJ4joqVAWW
=0oDb
-----END PGP SIGNATURE-----
 
E

efandango

John

please Ignore my penultimate post. I got it to work! (with your help of
course).

As mentioned the previous version drew a blank on the 'Both' option, which
seemed to be struggling on the 'Or' variance. Obviously I can see an orderly
layout on my QBE grid, and I realised that all the preceding 'seed' fields
were using the 'OR' option on two separate lines per field; so I pasted your
two lines into the two separate lines for corresponding each 'seed' field,
and hey presto!

thanks so much John.

regards

Eric

The SQL that works:

SELECT TOP 18 tbl_points.Run_No, tbl_points.Run_Point_Postcode,
tbl_PostCodes.Area, tbl_PostCodes.District, tbl_points.Point_Type,
tbl_points.Getround_Flag, tbl_points.Point_ID, tbl_points.Run_point_Venue,
tbl_points.Run_point_Address
FROM tbl_points LEFT JOIN tbl_PostCodes ON tbl_points.Run_Point_Postcode =
tbl_PostCodes.Postcode
WHERE (((tbl_points.Run_No) Between
[Forms]![frm_Runs].[cbo_Point2Point_From] And
[Forms]![frm_Runs].[cbo_Point2Point_To] And
(tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No) Between [Forms]![frm_Runs].[cbo_Point2Point_From]
And [Forms]![frm_Runs].[cbo_Point2Point_To] And
(tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,False,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Run_Point_Postcode) Between
[Forms]![frm_Runs].[cbo_Point2Point_Postcode_From] And
[Forms]![frm_Runs].[cbo_Point2Point_Postcode_To] And
(tbl_points.Run_Point_Postcode)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Run_Point_Postcode) Between
[Forms]![frm_Runs].[cbo_Point2Point_Postcode_From] And
[Forms]![frm_Runs].[cbo_Point2Point_Postcode_To] And
(tbl_points.Run_Point_Postcode)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,False,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_PostCodes.Area) Between [Forms]![frm_Runs].[cbo_Point2Point_Area_From]
And [Forms]![frm_Runs].[cbo_Point2Point_Area_To] And
(tbl_PostCodes.Area)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_PostCodes.Area) Between [Forms]![frm_Runs].[cbo_Point2Point_Area_From]
And [Forms]![frm_Runs].[cbo_Point2Point_Area_To] And
(tbl_PostCodes.Area)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,False,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_PostCodes.District) Between
[Forms]![frm_Runs].[cbo_Point2Point_District_From] And
[Forms]![frm_Runs].[cbo_Point2Point_District_To] And
(tbl_PostCodes.District)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_PostCodes.District) Between
[Forms]![frm_Runs].[cbo_Point2Point_District_From] And
[Forms]![frm_Runs].[cbo_Point2Point_District_To] And
(tbl_PostCodes.District)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,False,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Point_Type) Between
[Forms]![frm_Runs].[cbo_Point2Point_PointType_From] And
[Forms]![frm_Runs].[cbo_Point2Point_PointType_To] And
(tbl_points.Point_Type)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Point_Type) Between
[Forms]![frm_Runs].[cbo_Point2Point_PointType_From] And
[Forms]![frm_Runs].[cbo_Point2Point_PointType_To] And
(tbl_points.Point_Type)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,False,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
ORDER BY Rnd([Point_ID]) DESC;




John Spencer MVP said:
My fault, that should be OR between the two not AND

(tbl_points.Getround_Flag=
IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,True,
[Forms]![frm_Runs]![cbo_Point2Point_GetRounds]
OR
tbl_points.Getround_Flag=
IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,False,
[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])

The logic being that if the combobox returns 3 you will search for the value
being True or False. Otherwise you will search for the value being True or
True; or you will search for the value being False or False.

Again this query could get too complex to run.

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
John,

when I try your solution, the query/form fails to return anything when I
select 'both' from the combobox. MG Fosters also fails on the 'both'
criteria, so something must be wrong perhaps somewhere else, or have I got
the syntax wrong somehwere?

here is the line I am pasting into the SQL designer on field: [Getround_Flag]

here is the full SQL:


SELECT TOP 18 tbl_points.Run_No, tbl_points.Run_Point_Postcode,
tbl_PostCodes.Area, tbl_PostCodes.District, tbl_points.Point_Type,
tbl_points.Getround_Flag, tbl_points.Point_ID, tbl_points.Run_point_Venue,
tbl_points.Run_point_Address
FROM tbl_points LEFT JOIN tbl_PostCodes ON tbl_points.Run_Point_Postcode =
tbl_PostCodes.Postcode
WHERE (((tbl_points.Run_No) Between
[Forms]![frm_Runs].[cbo_Point2Point_From] And
[Forms]![frm_Runs].[cbo_Point2Point_To] And
(tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])
And
(tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,False,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Run_Point_Postcode) Between
[Forms]![frm_Runs].[cbo_Point2Point_Postcode_From] And
[Forms]![frm_Runs].[cbo_Point2Point_Postcode_To] And
(tbl_points.Run_Point_Postcode)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])
And
(tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,False,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_PostCodes.Area) Between [Forms]![frm_Runs].[cbo_Point2Point_Area_From]
And [Forms]![frm_Runs].[cbo_Point2Point_Area_To] And
(tbl_PostCodes.Area)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])
And
(tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,False,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_PostCodes.District) Between
[Forms]![frm_Runs].[cbo_Point2Point_District_From] And
[Forms]![frm_Runs].[cbo_Point2Point_District_To] And
(tbl_PostCodes.District)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])
And
(tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,False,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Point_Type) Between
[Forms]![frm_Runs].[cbo_Point2Point_PointType_From] And
[Forms]![frm_Runs].[cbo_Point2Point_PointType_To] And
(tbl_points.Point_Type)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])
And
(tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,False,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
ORDER BY Rnd([Point_ID]) DESC;





John Spencer said:
If you have one combobox with two columns and its properties set as
--Row source type: Value List
--Column widths: 0
--Row Source: 3;"Both",-1;"True",0;"False"
--Column Count: 2
--Bound Column: 1

You could change the criteria in the query to use this slightly more
complex statement.
tbl_points.Getround_Flag=IIF([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])
and
tbl_points.Getround_Flag=IIF([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,False,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])

MG Foster's proposed solution should work also; but you might run into a
query too complex error with his solution since Access often
significantly restructures the query's where clause using that solution.

'====================================================
John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
'====================================================

efandango wrote:
Yes, you're correct, I didn't need two combo boxes. I have been using 2
combos for the rest of the form where they were required and just had tunnel
vision regarding this particular combo. No I have a combo that has: Both;-1;0
which works perfectly, except I would prefer somthing more plain english,
like both; Yes; No

But if I use Yes, No, the query doesn't understand it. It seems to only like
the -1;0 criteria. Is their a way of having Yes and No either in the query or
perhaps a mask in the combo box, which I think is what Karl was trying to
explain to me in his reply?

my full SQL is:

SELECT TOP 18 tbl_points.Run_No, tbl_points.Run_Point_Postcode,
tbl_PostCodes.Area, tbl_PostCodes.District, tbl_points.Point_Type,
tbl_points.Getround_Flag, tbl_points.Point_ID, tbl_points.Run_point_Venue,
tbl_points.Run_point_Address
FROM tbl_points LEFT JOIN tbl_PostCodes ON tbl_points.Run_Point_Postcode =
tbl_PostCodes.Postcode
WHERE (((tbl_points.Run_No) Between
[Forms]![frm_Runs].[cbo_Point2Point_From] And
[Forms]![frm_Runs].[cbo_Point2Point_To] And
(tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]="Both",True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Run_Point_Postcode) Between
[Forms]![frm_Runs].[cbo_Point2Point_Postcode_From] And
[Forms]![frm_Runs].[cbo_Point2Point_Postcode_To] And
(tbl_points.Run_Point_Postcode)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]="Both",True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_PostCodes.Area) Between [Forms]![frm_Runs].[cbo_Point2Point_Area_From]
And [Forms]![frm_Runs].[cbo_Point2Point_Area_To] And
(tbl_PostCodes.Area)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]="Both",True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_PostCodes.District) Between
[Forms]![frm_Runs].[cbo_Point2Point_District_From] And
[Forms]![frm_Runs].[cbo_Point2Point_District_To] And
(tbl_PostCodes.District)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]="Both",True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Point_Type) Between
[Forms]![frm_Runs].[cbo_Point2Point_PointType_From] And
[Forms]![frm_Runs].[cbo_Point2Point_PointType_To] And
(tbl_points.Point_Type)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]="Both",True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
ORDER BY Rnd([Point_ID]) DESC;




:

efandango wrote:
I have a query field linked to a form combo box, like this:

Between [Forms]![frm_Runs].[cbo_Point2Point_Getrounds_From] And
[Forms]![frm_Runs].[cbo_Point2Point_Getrounds_To] And
<[Forms]![frm_Runs].[txt_Run_Limit]

In the form combo box I have a -1 or 0 choice. I want a third choice which
is All (or in plain english 'Both'. In other words if the user chooses
All/Both in the combobox, I want the query criteria to show all records.

The format in the combobox can be any format that will get the job done, at
the moment it is plain text. I have tried a Yes/No format but it will not
allow a third state. I want to avoid a checkbox because it is not obvious to
the user that a third state exists with that control.

How can I make the query criteria return All values when the user selects
All/Both instead of either just the -1 or 0s?
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I don't know why you have 2 ComboBoxes for this requirement - you only
need one.

I'll assume you're using a ValueList for the ComboBoxes' RowSource
properties.... Change them to this: Both, -1, 0

For your 2 ComboBoxes the criteria would be like this:

Between Forms!frm_Runs!cbo_Point2Point_Getrounds_From And
Forms!frm_Runs!cbo_Point2Point_Getrounds_To And
< Forms!frm_Runs!txt_Run_Limit
OR (Forms!frm_Runs!cbo_Point2Point_GetRounds_From = "Both"
OR Forms!frm_Runs!cbo_Point2Point_GetRounds_To = "Both")

If you had just one ComboBox your criteria would be like this:

IIf(Forms!frm_Runs!cbo_Point2Point_GetRounds="Both", True,
Forms!frm_Runs!cbo_Point2Point_GetRounds)

The "True" will cause the query to retury all records (if that is the
only criteria); otherwise the criteria would use -1 or 0, depending on
which one the user selected.

HTH,
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
** Respond only to this newsgroup. I DO NOT respond to emails **

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBSiBolIechKqOuFEgEQIEYgCgmtS/Sl7ClFYinlhTOp6tv4stdIUAnRZz
8n8j/Tjy1oQpnYKJ4joqVAWW
=0oDb
-----END PGP SIGNATURE-----
 
E

efandango

John,

I spoke too soon. When I reopened the database, I got the dreaded
'Expression too complex error....

your consistent predictions that it may be too complex have come to be true...

Is there another way of cracking this, or am I to live with the limitations
apparent?



John Spencer MVP said:
My fault, that should be OR between the two not AND

(tbl_points.Getround_Flag=
IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,True,
[Forms]![frm_Runs]![cbo_Point2Point_GetRounds]
OR
tbl_points.Getround_Flag=
IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,False,
[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])

The logic being that if the combobox returns 3 you will search for the value
being True or False. Otherwise you will search for the value being True or
True; or you will search for the value being False or False.

Again this query could get too complex to run.

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
John,

when I try your solution, the query/form fails to return anything when I
select 'both' from the combobox. MG Fosters also fails on the 'both'
criteria, so something must be wrong perhaps somewhere else, or have I got
the syntax wrong somehwere?

here is the line I am pasting into the SQL designer on field: [Getround_Flag]

here is the full SQL:


SELECT TOP 18 tbl_points.Run_No, tbl_points.Run_Point_Postcode,
tbl_PostCodes.Area, tbl_PostCodes.District, tbl_points.Point_Type,
tbl_points.Getround_Flag, tbl_points.Point_ID, tbl_points.Run_point_Venue,
tbl_points.Run_point_Address
FROM tbl_points LEFT JOIN tbl_PostCodes ON tbl_points.Run_Point_Postcode =
tbl_PostCodes.Postcode
WHERE (((tbl_points.Run_No) Between
[Forms]![frm_Runs].[cbo_Point2Point_From] And
[Forms]![frm_Runs].[cbo_Point2Point_To] And
(tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])
And
(tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,False,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Run_Point_Postcode) Between
[Forms]![frm_Runs].[cbo_Point2Point_Postcode_From] And
[Forms]![frm_Runs].[cbo_Point2Point_Postcode_To] And
(tbl_points.Run_Point_Postcode)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])
And
(tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,False,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_PostCodes.Area) Between [Forms]![frm_Runs].[cbo_Point2Point_Area_From]
And [Forms]![frm_Runs].[cbo_Point2Point_Area_To] And
(tbl_PostCodes.Area)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])
And
(tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,False,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_PostCodes.District) Between
[Forms]![frm_Runs].[cbo_Point2Point_District_From] And
[Forms]![frm_Runs].[cbo_Point2Point_District_To] And
(tbl_PostCodes.District)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])
And
(tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,False,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Point_Type) Between
[Forms]![frm_Runs].[cbo_Point2Point_PointType_From] And
[Forms]![frm_Runs].[cbo_Point2Point_PointType_To] And
(tbl_points.Point_Type)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])
And
(tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,False,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
ORDER BY Rnd([Point_ID]) DESC;





John Spencer said:
If you have one combobox with two columns and its properties set as
--Row source type: Value List
--Column widths: 0
--Row Source: 3;"Both",-1;"True",0;"False"
--Column Count: 2
--Bound Column: 1

You could change the criteria in the query to use this slightly more
complex statement.
tbl_points.Getround_Flag=IIF([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])
and
tbl_points.Getround_Flag=IIF([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,False,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])

MG Foster's proposed solution should work also; but you might run into a
query too complex error with his solution since Access often
significantly restructures the query's where clause using that solution.

'====================================================
John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
'====================================================

efandango wrote:
Yes, you're correct, I didn't need two combo boxes. I have been using 2
combos for the rest of the form where they were required and just had tunnel
vision regarding this particular combo. No I have a combo that has: Both;-1;0
which works perfectly, except I would prefer somthing more plain english,
like both; Yes; No

But if I use Yes, No, the query doesn't understand it. It seems to only like
the -1;0 criteria. Is their a way of having Yes and No either in the query or
perhaps a mask in the combo box, which I think is what Karl was trying to
explain to me in his reply?

my full SQL is:

SELECT TOP 18 tbl_points.Run_No, tbl_points.Run_Point_Postcode,
tbl_PostCodes.Area, tbl_PostCodes.District, tbl_points.Point_Type,
tbl_points.Getround_Flag, tbl_points.Point_ID, tbl_points.Run_point_Venue,
tbl_points.Run_point_Address
FROM tbl_points LEFT JOIN tbl_PostCodes ON tbl_points.Run_Point_Postcode =
tbl_PostCodes.Postcode
WHERE (((tbl_points.Run_No) Between
[Forms]![frm_Runs].[cbo_Point2Point_From] And
[Forms]![frm_Runs].[cbo_Point2Point_To] And
(tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]="Both",True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Run_Point_Postcode) Between
[Forms]![frm_Runs].[cbo_Point2Point_Postcode_From] And
[Forms]![frm_Runs].[cbo_Point2Point_Postcode_To] And
(tbl_points.Run_Point_Postcode)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]="Both",True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_PostCodes.Area) Between [Forms]![frm_Runs].[cbo_Point2Point_Area_From]
And [Forms]![frm_Runs].[cbo_Point2Point_Area_To] And
(tbl_PostCodes.Area)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]="Both",True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_PostCodes.District) Between
[Forms]![frm_Runs].[cbo_Point2Point_District_From] And
[Forms]![frm_Runs].[cbo_Point2Point_District_To] And
(tbl_PostCodes.District)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]="Both",True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Point_Type) Between
[Forms]![frm_Runs].[cbo_Point2Point_PointType_From] And
[Forms]![frm_Runs].[cbo_Point2Point_PointType_To] And
(tbl_points.Point_Type)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]="Both",True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
ORDER BY Rnd([Point_ID]) DESC;




:

efandango wrote:
I have a query field linked to a form combo box, like this:

Between [Forms]![frm_Runs].[cbo_Point2Point_Getrounds_From] And
[Forms]![frm_Runs].[cbo_Point2Point_Getrounds_To] And
<[Forms]![frm_Runs].[txt_Run_Limit]

In the form combo box I have a -1 or 0 choice. I want a third choice which
is All (or in plain english 'Both'. In other words if the user chooses
All/Both in the combobox, I want the query criteria to show all records.

The format in the combobox can be any format that will get the job done, at
the moment it is plain text. I have tried a Yes/No format but it will not
allow a third state. I want to avoid a checkbox because it is not obvious to
the user that a third state exists with that control.

How can I make the query criteria return All values when the user selects
All/Both instead of either just the -1 or 0s?
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I don't know why you have 2 ComboBoxes for this requirement - you only
need one.

I'll assume you're using a ValueList for the ComboBoxes' RowSource
properties.... Change them to this: Both, -1, 0

For your 2 ComboBoxes the criteria would be like this:

Between Forms!frm_Runs!cbo_Point2Point_Getrounds_From And
Forms!frm_Runs!cbo_Point2Point_Getrounds_To And
< Forms!frm_Runs!txt_Run_Limit
OR (Forms!frm_Runs!cbo_Point2Point_GetRounds_From = "Both"
OR Forms!frm_Runs!cbo_Point2Point_GetRounds_To = "Both")

If you had just one ComboBox your criteria would be like this:

IIf(Forms!frm_Runs!cbo_Point2Point_GetRounds="Both", True,
Forms!frm_Runs!cbo_Point2Point_GetRounds)

The "True" will cause the query to retury all records (if that is the
only criteria); otherwise the criteria would use -1 or 0, depending on
which one the user selected.

HTH,
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
** Respond only to this newsgroup. I DO NOT respond to emails **

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBSiBolIechKqOuFEgEQIEYgCgmtS/Sl7ClFYinlhTOp6tv4stdIUAnRZz
8n8j/Tjy1oQpnYKJ4joqVAWW
=0oDb
-----END PGP SIGNATURE-----
 
E

efandango

MG,

I pasted your where clause into the sql and ran the query from the form. If
I choose -1 or 0, I simply get a blank reply and completely blank forms; and
if I choose 'both', I get query too complex. I followed your suggestion of
pasting the sql, and not opening query designer. However, when the query
failed, I looked at it in the QBE grid; and for the criteria for the 'field':
IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds] Is
Null,True,[tbl_points].[Getround_Flag]=[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])

I see <>False on each line in that field column.



MGFoster said:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I believe you misunderstood my description of how to use the "Both", -1,
0 values in the criteria.

The IIf() formula is correctly stated as:

IIf(Forms!frm_Runs!cbo_Point2Point_GetRounds = 3, TRUE,
tbl_points.Getround_Flag=Forms!frm_Runs!cbo_Point2Point_GetRounds)

It should not be set up like this:

tbl_points.GetRound_Flag = IIF(Forms!.... etc. ... )

(see the WHERE clause I included [at the bottom])

The GetRound_Flag comparison to the Form value is made inside the IIf()
function.

The IIf() function will produce these results:

Both = 3 - TRUE : this ignores the values in GetRound_Flag, which
means ALL records are selected (consistent w/ the

other criteria).
True = -1 GetRound_Flag = -1 : only -1 values.
False = 0 GetRound_Flag = 0 : only 0 values.

===

To eliminate the "too complex" error, try this criteria. I've grouped
the ORs into the first section - enclosed in parentheses, and each
separate OR clause is enclosed in parentheses. Then I factored out the
common AND expressions and put them last.

If you change back to the Design Grid view the WHERE clause will be re
formatted by Access. I don't know if this is the query optimizer or
Access trying to get the SQL to match the Design Grid. Anyway, once you
have this working don't switch to the Design Grid - just save the query
from SQL View.

When I'm working on a query that I don't want the WHERE clause to
change, I copy the WHERE clause to a Notepad file before I switch back
to Design View. Then, when I switch back to SQL View, I replace the
Access formatted WHERE clause with the saved WHERE clause. Of course I
don't change the criteria in the Design Grid view, only in the SQL View.
This means learning the syntax of Boolean logic (i.e., where to put the
parentheses).


*** BE SURE TO BACK UP BEFORE TRYING THIS ***

=== My version of the criteria ===

WHERE (
tbl_points.Run_No BETWEEN Forms!frm_Runs!cbo_Point2Point_From
And Forms!frm_Runs!cboPoint2Point_to

OR (tbl_points.Run_Point_Postcode BETWEEN
Forms!frm_Runs!cbo_Point2Point_Postcode_From
And Forms!frm_Runs!cbo_Point2Point_Postcode_To
AND tbl_points.Run_Point_Postcode<Forms!frm_Runs!txt_Run_Limit)

OR (tbl_PostCodes.Area BETWEEN Forms!frm_Runs!cbo_Point2Point_Area_From
And Forms!frm_Runs!cbo_Point2Point_Area_To
AND tbl_PostCodes.Area<Forms!frm_Runs!txt_Run_Limit)

OR (tbl_PostCodes.District BETWEEN
Forms!frm_Runs!cbo_Point2Point_District_From
And Forms!frm_Runs!cbo_Point2Point_District_To
AND tbl_PostCodes.District<Forms!frm_Runs!txt_Run_Limit)

OR (tbl_points.Point_Type BETWEEN
Forms!frm_Runs!cbo_Point2Point_PointType_From
And Forms!frm_Runs!cbo_Point2Point_PointType_To
AND tbl_points.Point_Type<Forms!frm_Runs!txt_Run_Limit)
)

AND IIf(Forms!frm_Runs!cbo_Point2Point_GetRounds IS NULL, TRUE,
tbl_points.Getround_Flag=Forms!frm_Runs!cbo_Point2Point_GetRounds)

AND tbl_Points.Run_No<Forms!frm_Runs!txt_Run_Limit

===================== end SQL ======================

HTH,
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
** Respond only to this newsgroup. I DO NOT respond to emails **

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBSiXuWYechKqOuFEgEQLptACgnpgaXavAxQIU1Gvchl7+SLcWkokAoIq7
czJNGl4OF5MevDGs17NXox8d
=AByO
-----END PGP SIGNATURE-----
John,

I spoke too soon. When I reopened the database, I got the dreaded
'Expression too complex error....

your consistent predictions that it may be too complex have come to be true...

Is there another way of cracking this, or am I to live with the limitations
apparent?



John Spencer MVP said:
My fault, that should be OR between the two not AND

(tbl_points.Getround_Flag=
IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,True,
[Forms]![frm_Runs]![cbo_Point2Point_GetRounds]
OR
tbl_points.Getround_Flag=
IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,False,
[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])

The logic being that if the combobox returns 3 you will search for the value
being True or False. Otherwise you will search for the value being True or
True; or you will search for the value being False or False.

Again this query could get too complex to run.

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County

efandango wrote:
John,

when I try your solution, the query/form fails to return anything when I
select 'both' from the combobox. MG Fosters also fails on the 'both'
criteria, so something must be wrong perhaps somewhere else, or have I got
the syntax wrong somehwere?

here is the line I am pasting into the SQL designer on field: [Getround_Flag]

here is the full SQL:


SELECT TOP 18 tbl_points.Run_No, tbl_points.Run_Point_Postcode,
tbl_PostCodes.Area, tbl_PostCodes.District, tbl_points.Point_Type,
tbl_points.Getround_Flag, tbl_points.Point_ID, tbl_points.Run_point_Venue,
tbl_points.Run_point_Address
FROM tbl_points LEFT JOIN tbl_PostCodes ON tbl_points.Run_Point_Postcode =
tbl_PostCodes.Postcode
WHERE (((tbl_points.Run_No) Between
[Forms]![frm_Runs].[cbo_Point2Point_From] And
[Forms]![frm_Runs].[cbo_Point2Point_To] And
(tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])
And
(tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,False,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Run_Point_Postcode) Between
[Forms]![frm_Runs].[cbo_Point2Point_Postcode_From] And
[Forms]![frm_Runs].[cbo_Point2Point_Postcode_To] And
(tbl_points.Run_Point_Postcode)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])
And
(tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,False,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_PostCodes.Area) Between [Forms]![frm_Runs].[cbo_Point2Point_Area_From]
And [Forms]![frm_Runs].[cbo_Point2Point_Area_To] And
(tbl_PostCodes.Area)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])
And
(tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,False,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_PostCodes.District) Between
[Forms]![frm_Runs].[cbo_Point2Point_District_From] And
[Forms]![frm_Runs].[cbo_Point2Point_District_To] And
(tbl_PostCodes.District)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])
And
(tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,False,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Point_Type) Between
[Forms]![frm_Runs].[cbo_Point2Point_PointType_From] And
[Forms]![frm_Runs].[cbo_Point2Point_PointType_To] And
(tbl_points.Point_Type)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])
And
(tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,False,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
ORDER BY Rnd([Point_ID]) DESC;





:

If you have one combobox with two columns and its properties set as
--Row source type: Value List
--Column widths: 0
--Row Source: 3;"Both",-1;"True",0;"False"
--Column Count: 2
--Bound Column: 1

You could change the criteria in the query to use this slightly more
complex statement.
tbl_points.Getround_Flag=IIF([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])
and
tbl_points.Getround_Flag=IIF([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]=3,False,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])

MG Foster's proposed solution should work also; but you might run into a
query too complex error with his solution since Access often
significantly restructures the query's where clause using that solution.

'====================================================
John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
'====================================================

efandango wrote:
Yes, you're correct, I didn't need two combo boxes. I have been using 2
combos for the rest of the form where they were required and just had tunnel
vision regarding this particular combo. No I have a combo that has: Both;-1;0
which works perfectly, except I would prefer somthing more plain english,
like both; Yes; No

But if I use Yes, No, the query doesn't understand it. It seems to only like
the -1;0 criteria. Is their a way of having Yes and No either in the query or
perhaps a mask in the combo box, which I think is what Karl was trying to
explain to me in his reply?

my full SQL is:

SELECT TOP 18 tbl_points.Run_No, tbl_points.Run_Point_Postcode,
tbl_PostCodes.Area, tbl_PostCodes.District, tbl_points.Point_Type,
tbl_points.Getround_Flag, tbl_points.Point_ID, tbl_points.Run_point_Venue,
tbl_points.Run_point_Address
FROM tbl_points LEFT JOIN tbl_PostCodes ON tbl_points.Run_Point_Postcode =
tbl_PostCodes.Postcode
WHERE (((tbl_points.Run_No) Between
[Forms]![frm_Runs].[cbo_Point2Point_From] And
[Forms]![frm_Runs].[cbo_Point2Point_To] And
(tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]="Both",True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Run_Point_Postcode) Between
[Forms]![frm_Runs].[cbo_Point2Point_Postcode_From] And
[Forms]![frm_Runs].[cbo_Point2Point_Postcode_To] And
(tbl_points.Run_Point_Postcode)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]="Both",True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_PostCodes.Area) Between [Forms]![frm_Runs].[cbo_Point2Point_Area_From]
And [Forms]![frm_Runs].[cbo_Point2Point_Area_To] And
(tbl_PostCodes.Area)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]="Both",True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_PostCodes.District) Between
[Forms]![frm_Runs].[cbo_Point2Point_District_From] And
[Forms]![frm_Runs].[cbo_Point2Point_District_To] And
(tbl_PostCodes.District)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]="Both",True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
OR (((tbl_points.Run_No)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Point_Type) Between
[Forms]![frm_Runs].[cbo_Point2Point_PointType_From] And
[Forms]![frm_Runs].[cbo_Point2Point_PointType_To] And
(tbl_points.Point_Type)<[Forms]![frm_Runs].[txt_Run_Limit]) AND
((tbl_points.Getround_Flag)=IIf([Forms]![frm_Runs]![cbo_Point2Point_GetRounds]="Both",True,[Forms]![frm_Runs]![cbo_Point2Point_GetRounds])))
ORDER BY Rnd([Point_ID]) DESC;




:

efandango wrote:
I have a query field linked to a form combo box, like this:

Between [Forms]![frm_Runs].[cbo_Point2Point_Getrounds_From] And
[Forms]![frm_Runs].[cbo_Point2Point_Getrounds_To] And
<[Forms]![frm_Runs].[txt_Run_Limit]

In the form combo box I have a -1 or 0 choice. I want a third choice which
is All (or in plain english 'Both'. In other words if the user chooses
All/Both in the combobox, I want the query criteria to show all records.

The format in the combobox can be any format that will get the job done, at
the moment it is plain text. I have tried a Yes/No format but it will not
allow a third state. I want to avoid a checkbox because it is not obvious to
the user that a third state exists with that control.

How can I make the query criteria return All values when the user selects
All/Both instead of either just the -1 or 0s?
-----BEGIN PGP SIGNED MESSAGE-----
 

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