Results 1 to 7 of 7
  1. #1
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664

    Form with mutliple record source (s0

    I have a form that needs to have more that one record source. Some of the information on the form can only be found in an
    additional table - a second table. Using just one table will not do it. So can a form have more than one table as its record source?

    Any help appreciated. Thanks in advance.



    Respectfully,


    Lou_Reed

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Create a query, linking the different tables you need, selecting the appropriate fields you need from each table.
    Then use the query as the Control Source of your form (note that queries can be sure as the Control Source for things like Forms and Reports, just as easily as Table can). Most Forms/Reports I have are based on queries, as you typically want to do most of the calculations and record selection in the query.

  3. #3
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    So can a form have more than one table as its record source?
    yes it can, but it might not be editable or able to insert new records. It is better to keep one table, one form and have associated tables on subform(s). e.g. mainform > invoice header, subform >invoice line details.

    The other thing to consider is whether you need to bring through the other table, just use a combobox e.g. mainform > invoice header, customer name> combobox bound to customerid

  4. #4
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    I am not instructing you to have more than one Table as its Control Source (each object, i.e. Form or SubForm, can have only one Control Source).
    I am saying to make a Query (out of your multiple tables), and use that as the Control Source.

    As Ajax pointed out, depending on the nature of your Query, some queries are editable, and some aren't (i.e. Aggregate Queries or many-to-many Queries are not editable). In those cases, you might need to use a Subform, like they recommended.

  5. #5
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Just to add to what the others have said -

    As they said, in order for one form to use data from more than one table, you have to able to join the tabes with a relationship in a query, and base the form on that. If the tables cannot be related, then the answer to your original question is No.

    If you have several tables with the exact same structure (field names etc), then you can use VBA to switch the form's record source from table one to another.

  6. #6
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    Quote Originally Posted by JoeM View Post
    Create a query, linking the different tables you need, selecting the appropriate fields you need from each table.
    Then use the query as the Control Source of your form (note that queries can be sure as the Control Source for things like Forms and Reports, just as easily as Table can). Most Forms/Reports I have are based on queries, as you typically want to do most of the calculations and record selection in the query.
    Can you give me an example of doing this?

    Is there an example at a website. M

    y books on Microsoft Access 2010 had to go back to the library so I do not have them now.

    I just need to see an example before I can be confident doing one myself.

    Any help appreciated.

    Respectfully,


    Lou_Reed

  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,929
    What exactly do you not understand about building a query?

    Use query builder and save as an object. Then in form RecordSource reference that query instead of table.

    Or

    In the form RecordSource property click the ellipsis (...) to open query builder. This will generate an SQL statement that will be stored directly in the property. No object saved.
    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: 5
    Last Post: 10-14-2014, 04:08 PM
  2. Replies: 5
    Last Post: 09-18-2013, 09:15 PM
  3. Change the record source on my form
    By BigMac4 in forum Forms
    Replies: 4
    Last Post: 09-19-2012, 12:36 PM
  4. Record source in form not updating
    By sephiroth2906 in forum Forms
    Replies: 3
    Last Post: 01-27-2012, 03:16 PM
  5. Form Record Source - Best practices.
    By ser01 in forum Forms
    Replies: 1
    Last Post: 06-11-2011, 11:32 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