Results 1 to 5 of 5
  1. #1
    CASKSCOB is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2019
    Posts
    2

    Listbox only showing first row of recordset

    Help!



    I have an Access 2013 application that worked fine until I run it from Access 365, (whatever that version is), I don't know. I have a form that has a listbox which has an ADODB recordset bound to it.
    The recordset pulls 55 rows. After I set the recordset property of the listbox to the Recordset it only shows the first row in the recordset data. The items collection of the listbox is also only showing 1 item.
    ???


    Dim sql As String
    'Dim cn As ADODB.Connection
    Dim RS As ADODB.Recordset


    sql = "Select DeliveryID,ShipDate from Deliveries where CustomerID = " & Me.cboCustomer & " ORDER BY ShipDate DESC"

    Set RS = New ADODB.Recordset
    ConnectData()

    With RS
    .CacheSize = 1000
    .ActiveConnection = gblConn
    .Source = sql
    .LockType = adLockOptimistic
    .CursorType = adOpenKeyset
    .Open
    End With

    Dim str As String

    If RS.EOF And RS.BOF Then MsgBox "No Deliveries found for this customer": Exit Sub


    'Set the list box's Recordset property to the ADO recordset
    'at this point the RS shows 55 rows



    Set Me.lboDeliveries.Recordset = RS

    'at this point the listbox displays only the first row of the recordset

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,530
    Could it be that the "List Rows" property of the list box has been set to 1
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    CASKSCOB is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2019
    Posts
    2
    Bob, That is an excellent idea but there is no listrows property for the listbox. Not even listed as a property in code.

    thanks.

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,530
    Quote Originally Posted by CASKSCOB View Post
    Bob, That is an excellent idea but there is no listrows property for the listbox. Not even listed as a property in code.

    thanks.
    Apologies. I was thinking of a combo box.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  5. #5
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Have never used Recordset property of a listbox. Why use that instead of its rowsource. If a rowsource isn't defined, can you have a list?
    M$ object model isn't much help on this as the examples are somewhat restricted to those applying to a form recordset property. It does infer that it's a way to get to a single record though. Perhaps that behaviour extends to a listbox recordset property as well.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Populate listbox with DAO Recordset
    By andrews in forum Programming
    Replies: 6
    Last Post: 04-18-2019, 02:58 PM
  2. ListBox not showing correct stating point
    By cuddles in forum Forms
    Replies: 15
    Last Post: 06-20-2014, 03:29 PM
  3. Populate listbox from Recordset
    By PATRICK in forum Access
    Replies: 8
    Last Post: 10-28-2013, 11:00 PM
  4. Replies: 19
    Last Post: 11-01-2012, 08:03 AM
  5. Recordset not showing alpha-numeric entries
    By rayhawk in forum Access
    Replies: 9
    Last Post: 10-29-2010, 08:15 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums