Results 1 to 10 of 10
  1. #1
    Join Date
    Aug 2004
    Posts
    364

    Unanswered: Open secomd form by selecting a row from listbox on first form?

    Hello,

    I have two forms, frmUsers and frmReferrals.

    On frmUsers I have a listbox which displays users (form tblUsers).

    I want to select a user from the listbox on frmUsers, and on the click of the command button open frmReferrals and display the referrals of the selected user.

    The problem is that frmReferrals also has its own listbox in which I can select a user to display referrals, and the record source is set to the listbox.

    So I need to find a way to enable me to open the second form and display the selected user.

    I have attached an example database with the two forms.
    Attached Files Attached Files

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    in the listbox's on click event place some code that opens the other form with a filter set to the selected item in the listbox
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Aug 2004
    Posts
    364
    Yes well that is the part I need some help with.

    If for example, I use Access's command button from the toolbar to start the wizard to open the other form and open the form to display specific data and then link userID to the listbox, the form opens, but the selected user is not displayed. Because the second form is linked to the listbox on the second form.

    So I need to find a way to click on a user in the first listbox, and have the second form open with the same user selected in the second listbox - to show the referrals for that user.

  4. #4
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Does this work for you?

    Open a second form to the record
    Paul

  5. #5
    Join Date
    Aug 2004
    Posts
    364
    Unfortunately not, I get message "the openaction form was cancelled".

    Have you had a look at the database I attached?

  6. #6
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    You already have the correct code under a non-existent button Command8. If I put that behind the current button and change the record source of the second form to the table, it works as expected. I would start that way, and if you want further clicks on the second form's listbox to change the data, use the after update event of that listbox to change the recordsource of the form, using the selection as a criteria.
    Paul

  7. #7
    Join Date
    Aug 2004
    Posts
    364
    Im not too sure how to use the after update of the second list box to change the record source of the form.

  8. #8
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Along the lines of:

    Me.RecordSource = "SELECT Field1, Field2 FROM TableName WHERE FieldName = " & Me.ListboxName

    Or you could set it to your existing query that uses the listbox in the criteria.
    Paul

  9. #9
    Join Date
    Aug 2004
    Posts
    364
    Cool, that works a treat! Thanks

  10. #10
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Happy to help!
    Paul

Posting Permissions

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