Results 1 to 3 of 3
  1. #1
    izoprene is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2011
    Posts
    2

    Form to search on a foreign id, then update the calling record.

    Hello there,
    I've been stuck on an access 2007 problem, which to me seems like a common thing to solve but I cannot
    find any information on how to solve it.

    This example shows what I mean. Take 2 tables;

    orders_table
    ------------
    order_id int primary key
    customer_id int (foreign key of customer_table customer_id field)
    order_ref text

    customer_table
    --------------
    customer_id int primary key
    company_name text
    contact_person text


    So I made an orders form like this to display and update the data;
    ---------------------------------
    Order ID: [order_id]

    Customer ID: [customer_id] {change_customer_button}
    Customer Name: [customer_name]


    Contact Person: [contact_person]

    order Reference: [order_ref]
    ----------------------------------

    I would like a button on the orders form like the one next to the Customer ID above which when pressed would open a modal search box, where you can search the customer_name field of the customer_table to drill down to the desired customer. It would show all the data about that customer. Once the desired customer is found, is there some way to close the modal box and return to the orders form (Via a 'Apply changes' to record type button?) which would now contain the NEW customer ID of the desired customer.

    I'm sure this has been done before, ie a search on an a foreign id field, which then updates the record with the new foreign id.

    Thanks in advance. :-)

  2. #2
    NTC is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2009
    Posts
    2,392
    a. you can make the CustomerID field in the Orders table be a LookUp field that looks at the customer table. This will change this field into a combobox/dropdown type field. (there is some resistance to this feature by professional developers - but it is a feature of the product).

    b. you can set up, at the form level, a combobox that looks at the customer list, and then put in some VBA in the AfterUpdate event that puts the information of this combobox into the field on the form.

    c. as variation of b. would be to use a popup form rather than a combobox - the concept is identical.

    both b & c presume your form is in single form mode and not continuous form mode.

    hope this helps.

  3. #3
    izoprene is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2011
    Posts
    2
    Hi HTC,
    Thanks for the quick reply. I think I'll go with the combobox idea, sounds like the neatest solution. Many thanks! :-)
    Last edited by izoprene; 10-29-2011 at 02:07 AM. Reason: typo.

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

Similar Threads

  1. same form for new and update record
    By lizu in forum Forms
    Replies: 3
    Last Post: 06-20-2011, 08:34 AM
  2. Replies: 3
    Last Post: 03-22-2010, 04:30 PM
  3. Replies: 3
    Last Post: 01-14-2010, 08:32 AM
  4. Replies: 0
    Last Post: 10-16-2008, 02:39 PM
  5. Search for record from a form
    By hcoakley in forum Forms
    Replies: 0
    Last Post: 11-26-2006, 11:23 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