Results 1 to 6 of 6
  1. #1
    Damo10 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2012
    Posts
    11

    Insert data into a subform

    Hi,

    I have a form with a sub form, on the main form I want the user to select a machine number and then when they have selected it I want to populate the required data into the sub form.

    In the sub form I have a field called "Seal" and another called "Quantity" what I require is to get the results from either a query or table and list all the seals & quantities for that machine.

    I have a table called "Machine" which has all the machine numbers and also fields called "Seal1", "Seal1Qty","Seal2, "Seal2Qty" all the way to Seal 10.



    I do not know how the best way to get this data into the sub form, any help would be great.

    Regards,

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    The subform table should look like: (assuming [machID]=1)

    tSeal
    [MachID], [Seal], [Qty]
    1, 1, 32
    1, 2, 44

    when you select a Machine on the master form.
    the sub form will sync using the [MachID] (properties of the subform, master key field, child key field)
    Your sub form has all 3 fields from tSeal, but [machID] can be invisible.
    the subform will fill in the [machID] because its linked to the master form ID.
    so you only need fill in
    seal= 1, Qty=32
    seal=2, Qty = 44
    up to 10

  3. #3
    Damo10 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2012
    Posts
    11
    Hi,

    Thanks for the reply.
    I am not sure how to do what you suggest, could you please give me more detail how to do this or can I post the database?

    Regards,

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    You need an UNBOUND control (possibly combobox) to input search criteria to locate existing machine record on main form. Subform container Master/Child Links properties will synchronize the forms so that only related records will display in sub form.

    The search combobox can be designed several ways. You could use the Control Wizard and let it build macro for the search and go to record code. Or build VBA procedure that uses any of several methods that either go to record or apply filter to form. Review http://www.allenbrowne.com/ser-62.html
    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.

  5. #5
    Damo10 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2012
    Posts
    11
    Hi,

    Thanks for the reply, I am not sure that is what I need.

    I have attached a pic of the table where the machine data is stored and the bottom part is the form with the subform.
    On the form when the user selects the machine number the subform is to insert the seal types and quantities for each seal from the machine table so that the user can then fill in the "Replaced" & "Failed"

    Regards,Click image for larger version. 

Name:	Pic.jpg 
Views:	8 
Size:	63.6 KB 
ID:	21451Click image for larger version. 

Name:	Pic2.jpg 
Views:	8 
Size:	79.3 KB 
ID:	21452

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Main form is bound to SealStripData and subform is bound to tblSealStripDetail?

    User will have to input Seal in the subform to create record. VBA code can automate creation of a set of records but it can be a bit complicated, especially since Machine table is not a normalized data structure.

    I think SealsInfo should be linked to a normalized Machine table, not to tblSealStripDetail.

    The advice about search and go to existing record in main form still applies.
    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: 1
    Last Post: 03-22-2015, 02:21 PM
  2. Subform INSERT INTO...VALUES Problem
    By dipitiduda2 in forum Programming
    Replies: 1
    Last Post: 04-14-2014, 09:55 AM
  3. INSERT query: insert new data only
    By drh in forum Access
    Replies: 2
    Last Post: 04-04-2014, 05:31 PM
  4. Replies: 1
    Last Post: 10-02-2013, 01:14 AM
  5. SubForm will not update after an insert
    By kowalski in forum Forms
    Replies: 11
    Last Post: 08-16-2013, 06:49 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