Results 1 to 5 of 5
  1. #1
    aaaaaaaccess is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2017
    Location
    scotland
    Posts
    3

    Dependant field/lookup

    I have been away from Access for some time, forgive me if this is waay to easy to be posting about:

    i have a tables: Enquiries, Customer and Contact.


    Customer has 1 or more Contacts (people who work for the customer)




    Enquiries has a single customer (customer_ID) and a single contact (contact_ID)


    How do i make it so that Contact is selectable in an Enquiries form but is restricted based on the selected Customer??

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    google 'cascading combo's' for a number of ways to do this. But in principle you need two combos, one for the customer and one for the contact

    the rowsource for cboCustomers would be for example

    Code:
    SELECT CustomerPK, CustomerName FROM tblCustomers
    the rowsource for cboContacts would be

    Code:
    SELECT ContactPK, ContactName FROM tblContacts WHERE CustomerFK=[cboCustomers]
    then in your cboCustomers after update event you would have

    Code:
    Private Sub cboCustomers_AfterUpdate()
    
        me.cboContacts.requery
        me.cboContacts=Null
    
    End Sub
    change all names to suit your actual table, field and control names

  3. #3
    aaaaaaaccess is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2017
    Location
    scotland
    Posts
    3
    Ahh.. you're jogging my memory here. Thanks Ajax, this ought to be enough for me to work with!

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722

  5. #5
    aaaaaaaccess is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2017
    Location
    scotland
    Posts
    3
    Hi orange, yes, those were useful, I've got it working now. Thanks!

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

Similar Threads

  1. Replies: 4
    Last Post: 03-17-2016, 07:16 AM
  2. Lookup values not appearing in Lookup field?
    By dominover in forum Access
    Replies: 4
    Last Post: 03-05-2016, 05:01 PM
  3. Only allow values dependant on other box
    By AussieGal in forum Access
    Replies: 1
    Last Post: 03-28-2013, 03:22 AM
  4. Replies: 1
    Last Post: 09-13-2010, 01:57 PM
  5. Replies: 1
    Last Post: 03-22-2010, 03:37 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