assign value to take all records

  • Thread starter Thread starter AlexD
  • Start date Start date
A

AlexD

Hi everybody,

If I have in the query's desing view in Criteria for
[Distributor] field the following:
[Forms]![frmDistributors].[cboDistr] to take rows for some
specific distributors, which can be chosen from combobox
associated with some Distributors table.

How could I show in this combobox the option "All" and how
I could assign this value to [Forms]![frmDistributors].
[cboDistr] to retrieve all rows for all distributors?

Thanks
 
Thanks. I think partly it can be resolved by using
Like ([Forms]![frmDistributors].[cboDistr] *)
and assigning Null or "" to [Forms]![frmDistributors].
[cboDistr] if it's All.
 
AlexD said:
Hi everybody,

If I have in the query's desing view in Criteria for
[Distributor] field the following:
[Forms]![frmDistributors].[cboDistr] to take rows for some
specific distributors, which can be chosen from combobox
associated with some Distributors table.

How could I show in this combobox the option "All" and how
I could assign this value to [Forms]![frmDistributors].
[cboDistr] to retrieve all rows for all distributors?
Hi AlexD,

Hard to tell you exactly w/o seeing
source of cboDistr.

But as a simple example,
assume that cbo source =

SELECT DISTINCT Dist FROM tblDist;

to show "All" in cboDistr, change source to:

SELECT "All" As Distr FROM tblDist UNION SELECT DISTINCT Dist FROM tblDist;

Then, in query (using method once demonstrated by Duane)

WHERE [Distr] =
IIf[Forms]![frmDistributors].[cboDistr] ="All", [Distr],
[Forms]![frmDistributors].[cboDistr] )

So, if cboDistr = "All", you end up with

WHERE [Distr] = [Distr]

thus returning all records where [Distr] is not Null.

(Null=Null gives "not true" so does not return record)

pretty clever!

Good Luck,

Gary Walter
 
Thanks a lot, Gary.

Alex
-----Original Message-----

Hi everybody,

If I have in the query's desing view in Criteria for
[Distributor] field the following:
[Forms]![frmDistributors].[cboDistr] to take rows for some
specific distributors, which can be chosen from combobox
associated with some Distributors table.

How could I show in this combobox the option "All" and how
I could assign this value to [Forms]![frmDistributors].
[cboDistr] to retrieve all rows for all distributors?
Hi AlexD,

Hard to tell you exactly w/o seeing
source of cboDistr.

But as a simple example,
assume that cbo source =

SELECT DISTINCT Dist FROM tblDist;

to show "All" in cboDistr, change source to:

SELECT "All" As Distr FROM tblDist UNION SELECT DISTINCT Dist FROM tblDist;

Then, in query (using method once demonstrated by Duane)

WHERE [Distr] =
IIf[Forms]![frmDistributors].[cboDistr] ="All", [Distr],
[Forms]![frmDistributors].[cboDistr] )

So, if cboDistr = "All", you end up with

WHERE [Distr] = [Distr]

thus returning all records where [Distr] is not Null.

(Null=Null gives "not true" so does not return record)

pretty clever!

Good Luck,

Gary Walter


.
 
Back
Top