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

    Unanswered: How to insert primary keys from two tables into an intersection table

    Hello,

    I need to insert the primary key fields from two tables into an intersection table between the two tables.

    The first table is called tblUsers, the second table is tblGroups. The two tables create a many-to-many relationship - One group can have many users, and one user can be a member of many groups. The intersection table is called tblLinkUsersGroups.


    I am displaying details from tblUsers and tblGroups each in their own listboxes on a form. I want to select a User and then select a Group and click a button to add the primary keys from each into the intersection table.

    Can anyone offer any suggestions?

    Many thanks,

    Tom
    Last edited by moss2076; 04-17-10 at 17:14.

  2. #2
    Join Date
    Aug 2004
    Posts
    364
    I think I may have sorted it with this code -
    Code:
    Dim stDocName As String
        Dim stLinkCriteria As String
    
        stDocName = "view_beneficiary_groups_frm"
         stLinkCriteria = "[beneficiary_id]=" & Me!lst_beneficiaries.Column(0)
            DoCmd.OpenForm stDocName, , , stLinkCriteria
    
        DoCmd.GoToRecord , , acNewRec
          
        Forms![view_beneficiary_groups_frm]![beneficiaryID] = Forms!main_frm.lst_beneficiaries.Column(0)
    
        Forms![view_beneficiary_groups_frm]![groupid] = Forms!main_frm.lst_link_groups.Column(0)
    But I get a textbox appearing when I click my event button and I have to enter the beneficiary ID number, why isn't it being picked up by the listbox row selection I make before I press the button?

Posting Permissions

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