Results 1 to 3 of 3
  1. #1
    Bronze Lounger
    Join Date
    Feb 2001
    Location
    Escondido, California, USA
    Posts
    1,458
    Thanks
    0
    Thanked 1 Time in 1 Post

    List Box Control Syntax (WXP Access 2000)

    What is the syntax for a control that displays a list box item on a report?
    The report is based on a query that ony returns the index number of the item in the list box, but I want to display the data associated with that index, i.e. column 2 of the list instead of column 1.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: List Box Control Syntax (WXP Access 2000)

    I doubt that a list box is what you really need. List boxes have very limited usefulness on a report, since they don't have CanGrow and CanShrink properties. On a form, a list box is used to display multiple items, but on a report, the control won't resize itself to accomodate all items.

    The easiest way to display the data you want is to modify the query to return the desired data; you may have to add another table to the query for this.

    Another way is to use DLookup: create a text box with control source
    =DLookup("[Name_of_Field]","[Name_of_Table]","[Name_of_Index]="&[Name_of_Index])
    with the appropriate names substituted.

    If you do want to use a list box, make sure that its row source is a query that returns the index and the data field. Set the column count to 2, and set column widths to 0" and 1". Set the control source to the index field.

  3. #3
    Bronze Lounger
    Join Date
    Feb 2001
    Location
    Escondido, California, USA
    Posts
    1,458
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: List Box Control Syntax (WXP Access 2000)

    Hi Hans,

    As it turns out I have a fixed number of items from the list box to be displayed on a report, so that isn't a problem.

    I finally realized that my report record source was a query that only included the list box index so I had no source for the list item.. I had to change the control's source to look up the list item in a separate table based on the index number passed by the query.

    Thanks again.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •