Results 1 to 9 of 9
  1. #1
    wlanssens is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2013
    Posts
    10

    Subform gives data to main form

    Hey!



    I'm trying to make a form which gets it information in the textboxes out of a selected row in a subform.
    So I have a form say frmMain which has a few textboxes on top and a subform below in table form, if I select a row in the table (subform) the information gets filled in in the textboxes on top.
    I haven't found a way to make it work like this.. somebody with an idea?

    Thanks!
    W.

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    In the subform's class module you can reference the main form's controls like this

    Forms!frmMainName![ControlName].value = Me.SomeControl

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    But a typical form/subform setup uses 2 tables. The tables are typically related in a 1 to Many relationship. The 1 side is in the Form and the many side is in the subform. For a given identifier in the 1 table (Mainform), the related records in the many table are displayed on the subform.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    You should give the subform container control a name different from the object it holds, like ctrDetails.

    Then, if you want a textbox on main form to reference a field/control on subform, the reference should be:

    =[ctrDetails].[Form]![fieldname]

    =[ctrDetails].[Form]![controlname]

    (those will give intellisense popup tips that list field and control names)

    or simply =[ctrDetails].[fieldname]

    But maybe what you really want is a Split form.
    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
    wlanssens is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2013
    Posts
    10
    I'll explain a bit more.. I have a table with workorders, with the columns workorder number, description, ...
    I have a second table with more in depth info on a specific workorder, like who is going to work on that order etc.. a one-to-many relationship.

    I want to have a form where I can see the table with different workorders, and if I select a specific workorder (row) in that table I can see more details (out of the second table) above that subform..
    Does it require VBA? Not that I won't manage but its been a while :-)

    thanks for the reply's!
    W.

  6. #6
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    I would try

    Code:
    Form1 <-----recordsource tblWORKOrders  This is the 1 table
         subForm<------recordsource tblWorkOrderDetailedDescriptions   THis is the many table
    The linkfields would be WorkOrderId

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Yes, some amount of code needed if you want to go beyond the intrinsic Access search/filter tools.

    Options:

    1. Follow orange's guidance and build a form/subform. Main form bound to Workorders and subform bound to WorkorderDetails. Have an unbound combobox on main form that lists workorder numbers or customer that can be used to enter search criteria to either filter the Workorder dataset or go to record.

    2. synchronize two subforms, one bound to Workorder and one bound to WorkorderDetails: https://www.fmsinc.com/MicrosoftAcce...edSubforms.asp

    3. open a 'popup' form of the details
    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.

  8. #8
    wlanssens is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2013
    Posts
    10
    Okay, I'll give these options a try and see which one fits best :-)
    Thanks for the assistance!

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Probably should ignore option 3 - I didn't think that one out well.
    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. Subform - autofill data from main form
    By Kelly_D in forum Access
    Replies: 3
    Last Post: 03-20-2012, 11:36 AM
  2. copy data from a subform to the main form
    By declanfogarty in forum Programming
    Replies: 1
    Last Post: 06-23-2011, 05:31 AM
  3. Replies: 1
    Last Post: 06-14-2010, 02:31 AM
  4. Replies: 4
    Last Post: 05-17-2010, 05:32 PM
  5. Replies: 2
    Last Post: 03-31-2010, 01:56 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