Results 1 to 5 of 5
  1. #1
    dccjr3927 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Posts
    130

    Calling a Form control from a Subform

    Good Day. I have a form that contains a sub-form. The sub-form has a command button to insert the contents of the sub-form into a table. I am trying to reference a textbox on the main form for the order number. It is a one to many situation where the main form information is a single order and the subform has multiple entries for the order.



    Code:
    strInsertItemSQL = "INSERT INTO OrderDetails (OrderNo, SKU, Qty, ArtStatus, ArtProvided, PZInfo, Process, Date_Time)" _
            & "VALUES ('" & Forms!frmNewWO!tbxNewOrderNo.Value & "'& Me.cbxItemSKU & Me.tbxSKUQty.Value & '" & Me.cbxArtStatus & "','" & Me.chkProvided & "','" & Me.tbxPZInfo & "','" & Me.cbxProcess1 & "','# & Date_Time & #');"
    I have tried a couple of different variants (Forms!tbxNewOrderNo, Forms.tbxNewOrderNo, Forms!NewWO!tbxNewOrderNo, Forms!NewWO.tbxNewOrderNo, Parent!tbxNewOrderNo). I have gotten a couple of different errors: object not supported, number of query calues and destination..., etc.

    As always, any assistance would be greatly appreciated.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    Why do you need code for this?
    Are your forms bound?
    Why not just use subform container Master/Child Links and let Access do this work for you?
    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
    dccjr3927 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Posts
    130
    Hi June7. I am not familiar with subforms at all. This is my first attempt. Is there a way to bind the subform to the main after creation?

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    That's what Master/Child Links properties are for. These are properties of subform/subreport container control. Select the container and set properties.
    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
    dccjr3927 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Posts
    130
    Got it. Thanks as always.

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

Similar Threads

  1. Replies: 3
    Last Post: 12-06-2018, 03:27 PM
  2. Replies: 1
    Last Post: 06-13-2015, 06:31 AM
  3. Replies: 10
    Last Post: 02-20-2013, 07:04 AM
  4. Replies: 3
    Last Post: 03-29-2012, 12:40 PM
  5. Replies: 3
    Last Post: 03-02-2012, 03:27 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