Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2003
    Posts
    126

    Unanswered: Listbox Question

    Hi ya,

    This one has me stumped... I would like to take information from a table and put it into a listbox.

    I am having problems with getting the date to go into each column. what should the .additem line look like?

    Do While Not RGRecordset.EOF
    lstReportInformation.AddItem RGRecordset.Fields("Description")
    RGRecordset.MoveNext
    Loop

    I have 14 fields.

    Thanks,

    Ken

  2. #2
    Join Date
    Jan 2003
    Location
    Rockville, MD
    Posts
    179
    Hi GA_KEN,

    Try this.
    Code:
    Do While Not RGRecordset.EOF
       lstReportInformation.AddItem
       lstReportInformation.Column(0, lstReportInformation.ListCount-1) = _
          RGRecordset.Fields("Description")
       lstReportInformation.Column(1, lstReportInformation.ListCount-1) = _
          RGRecordset.Fields("Second Field")
       lstReportInformation.Column(2, lstReportInformation.ListCount-1) = _
          RGRecordset.Fields("Third Field")
       RGRecordset.MoveNext
    Loop

  3. #3
    Join Date
    Jan 2003
    Posts
    126

    Unhappy

    Originally posted by JTRockville
    Hi GA_KEN,

    Try this.
    Code:
    Do While Not RGRecordset.EOF
       lstReportInformation.AddItem
       lstReportInformation.Column(0, lstReportInformation.ListCount-1) = _
          RGRecordset.Fields("Description")
       lstReportInformation.Column(1, lstReportInformation.ListCount-1) = _
          RGRecordset.Fields("Second Field")
       lstReportInformation.Column(2, lstReportInformation.ListCount-1) = _
          RGRecordset.Fields("Third Field")
       RGRecordset.MoveNext
    Loop
    I get an "Argument not Optional" error on the .additem statement. I tried moveing the .column line up to the additem, then I got and "Invalid use of null" statement.

    I know I have done this before somewhere, but I can't seem to remember where and how.

    It's close I think, but still doesn't work.

  4. #4
    Join Date
    Jan 2003
    Location
    Rockville, MD
    Posts
    179
    Hmmm.. that code works for me on the Microsoft Forms 2.0 list box control, which I chose for its multi-select capabilities. What kind of list box control are you using?

  5. #5
    Join Date
    Jan 2003
    Posts
    126
    Just using the one inside Access 2002.

    Might be something I am doing wrong.. For now to meet deadline I'm creating temp tables to do the same thing. I'll revisit the listbox tomorrow or early next week.

    I'll let you know what happens!

    Ken

  6. #6
    Join Date
    Jan 2003
    Posts
    126
    I took another look at this, and it does work, just make sure that you add the right control. It does not work with the Access Listbox.

    Ken

Posting Permissions

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