Results 1 to 4 of 4
  1. #1
    mhoulis is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Feb 2015
    Posts
    2

    How to populate fields on a form from a table that's different than the record source?

    I have a simple database for my business. I want to generate invoices.

    There are 2 tables - customers and invoices. The customer table has fields for the customer's name and billing address. It has an autonumber field (customer number) as a primary key.

    The invoice table has fields for the customer's first and last name, the customer number, description of work, and pricing info (labor, materials, etc). It has an autonumber field (invoice number) as a primary key.

    They have a one-to-many relationship. (customers being the "one")

    I would like to use a form to enter new invoices to the invoice table. I would like to select a customer's last name (I think from a combo box - this is part of the question) and have all of their billing info appear on the form. I would then enter new invoice info - description of work, prices, etc - into the new invoice record. I think the record source for the form would have to be the invoices table because that's where the new invoice info is going...is that right?

    My experience in Access so far is I've created various simple tables, queries with various criteria, forms, and reports. I've used a combo box on a form to select a record and display the various fields for the selected record. I've changed properties of various objects and controls, tried a few simple macros. I have not ventured into VBA yet.

    Where I'm stuck is when I want to add a new invoice table record, I can't seem to be able to use the combo box to select a record from the customers table and populate the fields in the new invoice form. From other posts and forums I've looked at, it seems to relate to row sources and the table record source - this is where I'm confused. Also, is using a combo box to select a customer the best way to get the data - ALL of the billing info, not just the last name - from the customers table?

    In summary, I would like to use a form to add a new record to the invoice table and have the customer's billing info (address, etc - which are fields in the customer table) appear on the form when I select their last name from a list. Or as a result of typing in their last name with an auto-complete type of function. I would then proceed to enter in the invoice data into the fields from the invoice table.

    Once the new invoice table record is created, I would like to do the same in a report - pull the billing info from the customer table and invoice details from the invoice table.

    Thank you. I hope this is enough information and that I've described the problem clearly.

  2. #2
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    The one-to-many relationship means that you should be using a Main Form/Subform design, here. You shouldn't have the customers names in your Invoice Table; that violates a cardinal rule of relational databases! The customer ID number, the Primary Key for the Customer Table, should be the used to link the Main Form (RecordSource of which is the Customers Table) to the Subform, whose RecordSource would be the Invoice Table.

    When needing to enter a new invoice, you move to the customer in the Main Form and the invoices for that customer will appear in the Subform.

    For the Report, use a Query to pull the data you need from both Tables.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  3. #3
    mhoulis is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Feb 2015
    Posts
    2
    Thank you, sir.

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Glad we could help!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

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

Similar Threads

  1. form - record source - select a table
    By johnseito in forum Access
    Replies: 13
    Last Post: 11-15-2013, 02:54 PM
  2. populate a field from multiple source fields using a combobox
    By tranquillity in forum Database Design
    Replies: 8
    Last Post: 09-13-2013, 06:46 PM
  3. Replies: 3
    Last Post: 08-19-2012, 12:12 PM
  4. Replies: 4
    Last Post: 05-09-2012, 07:20 AM
  5. Replies: 2
    Last Post: 11-29-2010, 11:16 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