Results 1 to 3 of 3
  1. #1
    Comtech is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    19

    Create Pull Down Menu based on 2 tables

    Hello again. Does anybody have a solution to the following problem?

    I have 2 tables (tblListofActivities and tblActivities) that are linked by a 1 to many relationship. The tblListofActivities (which is the 1 side) just lists all the events for the entire year. The second table (tblActivities) will only get data as each event occurs. So the tblListofActivities will have many entries where there are no entries with the same ActivityID as the other table because the event hasn't occurred yet.
    I want to use a combo box that will only list the events that have occurred, and will not show those items that doesn't have an ActivityID associated with tblListofActivities .

    Hope this makes sense because I'm not sure how else to word it.



    Right now, I have the following line of code, but it lists all items in the table.

    [Forms]![frmFindbyLastName]![LastName].RowSource = "SELECT DISTINCTROW [tblListofActivities].[ActivityDate] , [tblListofActivities].[ActivityName] FROM [tblListofActivities] ORDER BY [ActivityDate],[ActivityName];"


    Any help would be appreciated. Thank you.
    Comtech

  2. #2
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Use an inner join to the tblActivities table. You don't need to select anything from tblActivities, but the inner join will only show rows where there are corresponding records in tblActivities:

    "SELECT DISTINCTROW [tblListofActivities].[ActivityDate] , [tblListofActivities].[ActivityName] FROM [tblListofActivities] inner join [tblActivities] on [tblListofActivities].[ActivityID] = [tblActivities].[ActivityID] ORDER BY [ActivityDate],[ActivityName];"

    Change ActivityID to the name(s) of the field(s) you use to relate the two tables.

  3. #3
    Comtech is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    19
    John_G
    Thank you for the reply. I just had to indicate which table to ORDER [ActivityDate] and [ActivityName] by, but this worked perfect.\

    Thanks again.
    Comtech

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

Similar Threads

  1. Replies: 2
    Last Post: 06-16-2017, 04:27 PM
  2. Pull down menu at run time in queries
    By elico in forum Queries
    Replies: 1
    Last Post: 02-08-2016, 12:45 PM
  3. Replies: 2
    Last Post: 08-07-2015, 02:11 AM
  4. Replies: 0
    Last Post: 09-25-2012, 09:16 AM
  5. Create tables based on field value
    By fpmsi in forum Programming
    Replies: 5
    Last Post: 11-17-2011, 12:42 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