Results 1 to 4 of 4
  1. #1
    KrisDdb is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    58

    Question Link two forms to display related data

    I have a main form with a list box that has 7 fields, which get their values from a query (the query returns 10 fields in total out of which I am using only 7 to populate the main form). Out of these 7 fields, there is a unique field “key_no”. Now I am trying to open a second form which would have details of the remaining 3 fields (out of the total 10 from the query). The catch is, I want the second form to display only one record’s field values, the record being the one selected from the list box on the main form. I want the second form to open as a pop up (can be avoided if not possible) and also be able to be edited and saved with new data input by the user. This second form would open up when a record is double clicked in the list box on the main form. I am not able to figure out how to link both the forms.
    Please give me some suggestions. Appreciate your time and thoughts.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    How about this?

    BaldyWeb wherecondition
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    KrisDdb is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    58

    Question Tried something similar

    Hey Paul.. Thanks for the quick reply.

    I tried something similar. Heres the code for it:


    Dim stDocName As String

    stDocName = "frm2"
    DoCmd.OpenForm stDocName, , , "key_no = " & Me.key_no, acFormEdit, acDialog

    I put the above code in the double click event procedure for the list box (list23). The unique field name is 'key_no' on both the forms. But still the frm2 is displaying the wrong data. Where am I going wrong?

    Edit: oh and the key_no is a unique number.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    The wrong data, or all data? Do you know how to set a breakpoint and check that Me.key_no is returning what you think it should? Can you post the db? Oh, and I would expect Me.Key_no to be Me.list23, so it got the value from the listbox. As is, it's getting whatever record is displayed on the form.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 12
    Last Post: 10-20-2014, 11:22 AM
  2. Link to Forms
    By Luke in forum Forms
    Replies: 1
    Last Post: 07-14-2011, 08:51 AM
  3. query won't display records with no related records
    By James Brazill in forum Queries
    Replies: 1
    Last Post: 06-28-2011, 02:10 AM
  4. Replies: 4
    Last Post: 12-21-2010, 11:32 AM
  5. Display Link
    By ellechim in forum Import/Export Data
    Replies: 0
    Last Post: 06-30-2010, 08:46 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