Results 1 to 10 of 10

Thread: How to select the next record on a data list with a command button.

  1. #1
    Join Date
    Apr 2013
    Posts
    8

    How to select the next record on a data list with a command button.

    Hello everyone. I would like to see if someone could help me with this question. I have a form and on that form I have a data list. I want to be able to go to the next record on the data list but using a command button. I would actually like to have two buttons, one for the next record and another for the previous record. I know it can be done by using the up and down keys on the keyboard but I still wanted to see if it was possible to do this. Thanks. I am using Microsoft ACCESS 2000. I know, its old, but it works for me at the moment.

  2. #2
    Join Date
    Apr 2013
    Location
    Laurel, MD
    Posts
    27
    Hi nightclub. I just did a similar thing in my database in access 2007. It has been a long time since I have used 2000, but the steps should be similar.

    Here are the steps: Open your form in design view. Select the ‘Command Button’ on your menu bar, then click on any empty space in your form. This will open the ‘Command Button Wizard’ window. Just follow the steps of the wizard.

    Hope this helps. Good luck

  3. #3
    Join Date
    Apr 2013
    Posts
    8
    Thank you for responding. I did try that but it did not work. I think it did not work because the form was not bound to any table or query. I did not want to bind the form to a table because this form has several tabs and each tab has a data list on it.

  4. #4
    Join Date
    Apr 2013
    Location
    Laurel, MD
    Posts
    27
    Ok. If I am not mistaken you will have to create a query and bind the form directly to it. So create a query for each of your tabs with a criteria for each data list. I tried creating a standalone forms with my current database the way you did, then add the command buttons and it did not work. The form has to be linked to something in order for the information to be retrieved through the command button.

  5. #5
    Join Date
    May 2006
    Posts
    407
    You are asking how to select the next "record" with a command button, then you say the "data list" is not bound to any table (or query). Therefore, the rows that are in your "data list" are NOT records. At least not in the sense that Access looks at records.
    If you want to go down one row from where the cursor is in your individual rows of data within the "data list," then you will have to write some code for that command button. That code will have to know what row the cursor was in, and then add 1 or subtract 1, depending on going up or down within the "data list." I'm putting "data list" in quotes because I have no idea what type of control you are using that you are calling a "data list."
    There is a lot more information that you need to provide before we can help you intelligently.

  6. #6
    Join Date
    Apr 2013
    Posts
    8
    Yes, that't it. That is exactly what I would like to do. Thank you very much. I want to go down one row from where the cursor is in the individual rows of data within the "data list". Similar to the up and down buttons on a keyboard. Once a data list is selected, focus is on the data list, I would like to have a button to go up one row and a second button that will go down one row.

  7. #7
    Join Date
    May 2006
    Posts
    407
    now explain how you got the data into this quote data list quote.as I said before I have no idea what a data list is that you are talking about.
    When someone is asking for help, they (you) need to read the answers they get carefully and answer all questions. Go back and reread my last response to you and answer all the questions I asked.

  8. #8
    Join Date
    Apr 2013
    Posts
    8
    I have a form. The form is not bound to a table or query. The form has a "List Box". The "List Box" displays a list of customer names. The "List Box" is bound to a "table" that has customer information. Column 1, of the "List Box", displays the customer's first name, column 2, of the "List Box", displays the customer's last name. I want to add 2 "command buttons" to the form. One "command button" will move the cursor down one row from the individual rows of data within the "List Box". The second "command button" will move the cursor up one row from the individual rows of data within the "List Box".

  9. #9
    Join Date
    May 2006
    Posts
    407
    To retrieve the index of the ListBox, use this (where "myListBox" would be the name of the ListBox you are using):
    Me.myListBox.ListIndex
    If you refer to the above code on the right side of an equal (=) sign, the variable on the left of the equal sign will get the current index of the ListBox.
    -1 means no item has been selected in the list.
    0 is for the first item in the list, 1 for the second, etc.

    If you code something like: Me.myListBox.ListIndex = 5 that would select the 6th item on the list.

  10. #10
    Join Date
    Apr 2013
    Posts
    8
    Thank you very much for your help for your help. It is greatly appreciated.

Posting Permissions

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