Results 1 to 5 of 5
  1. #1
    smcfadden777 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Mar 2012
    Posts
    3

    Transfer ID from Form to Query Subform field

    I have seen alot of posts that are similar but not the same as my problem. Seems like it should not be difficult.

    I would like to send the ID from a form to a subform query after I have added a record to that subform query.

    I have 2 table "Clients". which has an ID for each client and a table "Payments" which records the payments made by the client. I have a main form to display the clients name and ID.

    I have a query that I have put into a subform that displays the clients payments on the main form.
    Click image for larger version. 

Name:	subform.jpg 
Views:	17 
Size:	77.7 KB 
ID:	6585


    How can I have the ID field in the subform automatically populated with the Client ID on the form when I add a payment to this subform?

    Thank you.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Have you set Master/Child links of the subform container control? This linking will synchronize the related records. As soon as any entry made in subform record the ID will populate in the subform record.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    smcfadden777 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Mar 2012
    Posts
    3
    I deleted that attempt but need to still do it, I will let you know.

    Thank you

  4. #4
    smcfadden777 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Mar 2012
    Posts
    3
    I remade the subform and did as instructed and it worked fine. Turns out I had originally draged and dropped the subfrm onto the main form and did not have the benifit of an automatic connection.

    Still have a problem though, The main form has gotten too crowded. I need to make the subform, "Payments", a seperate form that can be brought up by clicking a button on the main form, and allow auto population of the ID field in a new record on the new form, with the ID of the main form. Same problem on a seperate form. Thank you.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Too crowded? Consider using tab control. Otherwise, need code.
    Options:

    1. Pass the ID value in the OpenArgs argument of DoCmd.OpenForm:
    DoCmd.OpenForm "secondformname", , , acFormAdd, , Me.textboxname
    Then Current event of form two:
    If IsNull(Me!ID) Then Me!ID = Me.OpenArgs

    2. first form code sets value of textbox on second form.
    Forms!secondformname.textboxname = Me.textboxname

    3. Second form refers to textbox on first form (first form must remain open):
    IIf(IsNull(Me!ID) Then Me!ID = Forms!firstformname textboxname
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Transfer date to another field
    By groovychick in forum Access
    Replies: 4
    Last Post: 12-20-2011, 06:13 AM
  2. Replies: 3
    Last Post: 10-03-2011, 02:33 PM
  3. Replies: 7
    Last Post: 01-12-2011, 08:59 AM
  4. Replies: 9
    Last Post: 12-15-2010, 01:44 PM
  5. Replies: 3
    Last Post: 11-05-2010, 03:10 PM

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