Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / January 2005

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DOYLE60 - 03 Jan 2005 14:07 GMT
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.)
Wayne Morgan - 03 Jan 2005 14:43 GMT
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"))

Signature

Wayne Morgan
MS Access MVP

>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
[quoted text clipped - 42 lines]
> get
> through. This is the thrid attempt.)
DOYLE60 - 04 Jan 2005 22:46 GMT
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"))

>>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
[quoted text clipped - 42 lines]
>> get
>> through. This is the thrid attempt.)
DOYLE60 - 06 Jan 2005 16:05 GMT
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
[quoted text clipped - 53 lines]
>> get
>> through. This is the thrid attempt.)
Duane Hookom - 03 Jan 2005 16:25 GMT
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.

Signature

Duane Hookom
MS Access MVP
--

>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
[quoted text clipped - 42 lines]
> get
> through. This is the thrid attempt.)
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.