Results 1 to 5 of 5
  1. #1
    Lounger
    Join Date
    Jan 2001
    Location
    Virginia, USA
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ListIndex question??? (Access 97)

    I have a listbox and two check boxes on a form. The only real purpose of the checkbox is to switch the bound control back and forth within the listbox. The actual rowsource remains the same. If I click on a record in the listbox, it becomes highlighted. If I then switch from one checkbox to the other, I want the record that was highlighted to remain that way. There is also a command button that will enter the information for the record that is highlighted into a table. After I enter information I would like the next record to be highlighted. If I have not made this sound too confusing, is it possible to do something like this? I have looked at using the listindex property but haven't been able to see where it will help me move to the next record. Is it even possible to use listindex in this way? Any suggestions on another way to skin the cat would be appreciated?

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

    Re: ListIndex question??? (Access 97)

    I don't understand what you mean by
    <hr>switch the bound control back and forth within the listbox<hr>
    but you can set the selected item in a list box by setting its value

    Dim i As Integer
    i = lbxTest.ListIndex
    ' Do something
    ' ...
    ' Set the previously selected item
    lbxTest = lbxTest.ItemData(i)
    ' or the next item
    If i < lbxTest.ListCount - 1 Then
    lbxTest = lbxTest.ItemData(i + 1)
    End If

  3. #3
    Lounger
    Join Date
    Jan 2001
    Location
    Virginia, USA
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: ListIndex question??? (Access 97)

    I realized what part of my problem was, I was being more complicated than what I needed in my code. Thanks for the help, I think I have it working...if not ...I will be back.

  4. #4
    Lounger
    Join Date
    Jan 2001
    Location
    Virginia, USA
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: ListIndex question??? (Access 97)

    I may have spoken too soon yesterday. Everything seems to be working fine except for one thing. When I click on a record in the listbox I run the following line of code:

    I = lstreportA.listindex

    Then when I enter a record into the new table I run the following line to move to the next record:

    lstreporta = lstreporta.itemdata(I+1)

    The problem that I am running into is that the column that is bound in lstreporta can have more than one of the same number. Everything will be running along fine moving to the next record until it hits a number that has been used before and then it moves to the first instance of that number in the table. Any suggestions?

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

    Re: ListIndex question??? (Access 97)

    Try

    lstReportA.Selected(l + 1) = True

    This just selects the next item.

Posting Permissions

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