Results 1 to 4 of 4
  1. #1
    alexandervj is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    145

    How to pass an ID though a button

    I'm trying to pass an ID from one form to another form when the user clicks a button as described in this thread...

    http://stackoverflow.com/questions/1...orm-to-another

    but I'm a noob and the thread doesnt explain it in enough detail. It sounds to me like i need to put this code in the buttons Onclick event:

    forms(parentFormName).recordset.fields(fieldName). value

    Is this correct? And how to I assign the ID to a value in the child form? Thanks!

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Is this a form/subform arrangement (one form installed on another form)? If yes, then set the Master/Child properties links of the subform container control and no code is required.
    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
    alexandervj is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    145
    I dont think its a subform, I have basically one popup modal form with details about a product lot, a button on this form labeled "Add" is to add a product to this product lot. When you press the add button another modal pops up ontop of the last form, but I dont want to have to fill out the lot information every time I want to enter a product, so I want to pass the LotID through the add button where I pick it up again in the "Add Product to this Lot" form and it assigns the appropriate Lot information based on the LotID

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    So why not a form/subform?

    There are several ways to go about populating the foreign key field with the LotID. One way is to set the DefaultValue property of textbox as a reference back to the calling form LotID field or control.
    Forms!formname.LotID

    Be sure to set textbox as Locked Yes and TabStop No.
    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. Replies: 14
    Last Post: 02-19-2013, 03:16 PM
  2. pass thru qry
    By slimjen in forum Forms
    Replies: 5
    Last Post: 07-18-2012, 09:36 AM
  3. Shift By Pass
    By pkstormy in forum Code Repository
    Replies: 4
    Last Post: 03-18-2012, 05:51 PM
  4. Pass from submform
    By Newbie11 in forum Forms
    Replies: 5
    Last Post: 02-20-2012, 07:16 PM
  5. pass value from one form to another
    By ManC in forum Forms
    Replies: 7
    Last Post: 11-25-2011, 09:59 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