How To Get Textbox on Report to Read All if Listbox Null

  • Thread starter Thread starter DOYLE60
  • Start date Start date
D

DOYLE60

I have a list box on a form that filters a report. It is set up so that if
nothing is chosen in the list box, the report prints all and if items are
chosen, then it just prints those items.

On the report header I have the items chosen in the list box. The control
source has this in it:

=enumrecord("PrintDialogInventoryFranchiseLBqry2")

This all works just fine.

But I want to make a slight change. Instead of listing all items if nothing is
chosen in the listbox, I want it instead to just say "All" in that case.

I tried a thing like this:

=IIf([Forms]![InventoryDialogPrintfrm]![FranchiseChosen] Is
Null,"All",enumrecord("PrintDialogInventoryFranchiseLBqry2"))

or this:

=IIf(Len([InventoryDialogPrintfrm].[Forms]![FranchiseChosen])=0,"All",enum
record("PrintDialogInventoryFranchiseLBqry2"))

I even attempted to write code in the OnOpen of the report for the control
source of the text box, doing a If-Else statement. But I can't seem to get it.

Any help would be greatly appreceiated.

The dialog Print form is: InventoryDialogPrintfrm
The Listbox is: FranchiseChosen
The Textbox on the report is: Franchisetxt
The query that holds the listbox items is: PrintDialogInventoryFranchiseLBqry2

Thanks again,

Matt

(This message has been repeated because I can't find my original post after I
choose all and keep on pressing the More button. It just doesn't seem to get
through. This is the thrid attempt.)
 
Is this a multiselect listbox? If so, instead of checking the value, check
for the number of items selected. If it is a single select listbox try

IsNull(Forms!....) instead of Forms!.... Is Null

Example:
=IIf([Forms]![InventoryDialogPrintfrm]![FranchiseChosen].[ItemsSelected].[Count]
= 0,"All",enumrecord("PrintDialogInventoryFranchiseLBqry2"))
 
All of your attempts to post this message have been successful. Please learn
how to find your previous postings so you can keep everything in a single
thread.
 
Thanks so much. This worked:

=IIf([Forms]![InventoryDialogPrintfrm]![FranchiseChosen].[ItemsSelected].[
Count]=0,"All",enumrecord("PrintDialogInventoryFranchiseLBqry2"))

Even though it is a multi-select.

Thanks again,

Matt

Is this a multiselect listbox? If so, instead of checking the value, check
for the number of items selected. If it is a single select listbox try

IsNull(Forms!....) instead of Forms!.... Is Null

Example:
=IIf([Forms]![InventoryDialogPrintfrm]![FranchiseChosen].[ItemsSelected].[
Count]=0,"All",enumrecord("PrintDialogInventoryFranchiseLBqry2"))

--
Wayne Morgan
MS Access MVP


DOYLE60 said:
I have a list box on a form that filters a report. It is set up so that if
nothing is chosen in the list box, the report prints all and if items are
chosen, then it just prints those items.

On the report header I have the items chosen in the list box. The control
source has this in it:

=enumrecord("PrintDialogInventoryFranchiseLBqry2")

This all works just fine.

But I want to make a slight change. Instead of listing all items if
nothing is
chosen in the listbox, I want it instead to just say "All" in that case.

I tried a thing like this:

=IIf([Forms]![InventoryDialogPrintfrm]![FranchiseChosen] Is
Null,"All",enumrecord("PrintDialogInventoryFranchiseLBqry2"))

or this:

=IIf(Len([InventoryDialogPrintfrm].[Forms]![FranchiseChosen])=0,"All",enum
record("PrintDialogInventoryFranchiseLBqry2"))

I even attempted to write code in the OnOpen of the report for the control
source of the text box, doing a If-Else statement. But I can't seem to
get it.

Any help would be greatly appreceiated.

The dialog Print form is: InventoryDialogPrintfrm
The Listbox is: FranchiseChosen
The Textbox on the report is: Franchisetxt
The query that holds the listbox items is:
PrintDialogInventoryFranchiseLBqry2

Thanks again,

Matt

(This message has been repeated because I can't find my original post
after I
choose all and keep on pressing the More button. It just doesn't seem to
get
through. This is the thrid attempt.)
 
Thanks. I got it to work witih th esecond example.

Matt


Is this a multiselect listbox? If so, instead of checking the value, check
for the number of items selected. If it is a single select listbox try

IsNull(Forms!....) instead of Forms!.... Is Null

Example:

=IIf([Forms]![InventoryDialogPrintfrm]![FranchiseChosen].[ItemsSelected]. [Count]

= 0,"All",enumrecord("PrintDialogInventoryFranchiseLBqry2"))

--
Wayne Morgan
MS Access MVP


DOYLE60 said:
I have a list box on a form that filters a report. It is set up so that if
nothing is chosen in the list box, the report prints all and if items are
chosen, then it just prints those items.

On the report header I have the items chosen in the list box. The control
source has this in it:

=enumrecord("PrintDialogInventoryFranchiseLBqry2")

This all works just fine.

But I want to make a slight change. Instead of listing all items if
nothing is
chosen in the listbox, I want it instead to just say "All" in that case.

I tried a thing like this:

=IIf([Forms]![InventoryDialogPrintfrm]![FranchiseChosen] Is
Null,"All",enumrecord("PrintDialogInventoryFranchiseLBqry2"))

or this:

=IIf(Len([InventoryDialogPrintfrm].[Forms]![FranchiseChosen])=0,"All",enum
record("PrintDialogInventoryFranchiseLBqry2"))

I even attempted to write code in the OnOpen of the report for the control
source of the text box, doing a If-Else statement. But I can't seem to
get it.

Any help would be greatly appreceiated.

The dialog Print form is: InventoryDialogPrintfrm
The Listbox is: FranchiseChosen
The Textbox on the report is: Franchisetxt
The query that holds the listbox items is:
PrintDialogInventoryFranchiseLBqry2

Thanks again,

Matt

(This message has been repeated because I can't find my original post
after I
choose all and keep on pressing the More button. It just doesn't seem to
get
through. This is the thrid attempt.)
 
Back
Top