Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2015
    Posts
    3
    Provided Answers: 1

    Answered: Double Click on listbox record in form, takes you to the recordset in the form.

    Hello Everyone,

    I am currently working on a form in Access 2013 where I have a query setup in a listbox that shows all assigned customers to a division. When you doubleclick on the listbox value, I want it to take you to that recordset in the form.

    Currently, my code looks like

    List215.Setfocus

    i = List215.Listindex +1

    DoCmd.GotoRecord AcDataForm, "Formname", AcGoto, i


    The problem is my listbox is a filtered query and when I run the above code, it takes me to a different record. I want to find a way to See what the primary key's value is of the users selection, then search the record set for that value then take you to that record.

    Any help would be appreciated.

  2. Best Answer
    Posted by Gueits24

    "I was able to solve this problem myself.

    I had to associate my form with my query instead of associating it with the table. In doing this My original code;
    Code:
    List215.Setfocus
    
    i = List215.Listindex +1
    
    DoCmd.GotoRecord AcDataForm, "Formname", AcGoto, i
    works as intended. When I double click on the record in the listbox, it navigates to the correct recordset in my form."


  3. #2
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    495
    Provided Answers: 24
    NO, dont use goto record
    open a query using that key in the listbox
    docmd.openquery "qsRec1Key"

    OR
    filter the existing data on that key via:
    Code:
    me.filter = "[ID]=" & me.listBox
    me.filterOn = true

  4. #3
    Join Date
    Jun 2015
    Posts
    3
    Provided Answers: 1
    Ran,

    The first option does not do what I want it to do. It does open the query, but the action I want to happen is when someone clicks on the listbox's value, It will auto populate the recordset in the form based off the selected item in the listbox

    My query's are just filtered based of the different divisions.

    Im not sure if the second option applies.

  5. #4
    Join Date
    Jun 2015
    Posts
    3
    Provided Answers: 1
    I was able to solve this problem myself.

    I had to associate my form with my query instead of associating it with the table. In doing this My original code;
    Code:
    List215.Setfocus
    
    i = List215.Listindex +1
    
    DoCmd.GotoRecord AcDataForm, "Formname", AcGoto, i
    works as intended. When I double click on the record in the listbox, it navigates to the correct recordset in my form.

  6. #5
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    495
    Provided Answers: 24
    If you dont want to filter, then call the form using the filter
    docmd.openform "frmMyform",,,"[ID]=" & listBox

Posting Permissions

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