Results 1 to 7 of 7
  1. #1
    Ramtrap is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Dec 2016
    Posts
    62

    Show Only Available Options in a Combo Box

    Hi all,
    I have an issue with a query not coming up how I want it to. I have a conference scheduling db whereby I have the tables, as below:
    Click image for larger version. 

Name:	AccessRelationships2.jpg 
Views:	18 
Size:	74.9 KB 
ID:	31355

    Note that I must have all the tables as some conferences may have only the one day, but some may have 3 or 4.
    What I need to find is the remaining Conference Days available for a person to be related to, after accounting for the ones he/she is already related to.

    For example: I have person (Alan) going to Conference XYZ. It is a 3 day conference, and Alan is going only for Day 1 right now.
    Here's what I know:


    My query for ALL the days available for Alan would look like this (note that the criteria is coming from another form with pre-populated fields):
    Click image for larger version. 

Name:	AllDaysAvailable.PNG 
Views:	17 
Size:	4.2 KB 
ID:	31356

    My query for the days my person is definitely going for that specific conference would look like this:
    Click image for larger version. 

Name:	AllDaysPersonAttending.PNG 
Views:	17 
Size:	5.6 KB 
ID:	31357

    What I can't, for the life of me, is figure out how to get the delta. I'm assuming I need to create a query from a query (i.e. start a new query using the first query as my framework and subtract the days I know my person is already going). Is that kind of the right track?

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    Q1, shows the persons and the days they attend conferences, qsPersonAttend
    Q2, shows the conferences and all the days, qsConfDays
    Q3, add in the 2 queries: qsPersonAttend and qsConfDays
    join the 2 on [ConfDate]
    make it an OUTER JOIN. Dbl-click the join line, set it to: ALL records in qsConfDays, some in qsPersonAttend
    bring down the dates from both
    qsPersonAttend.name, qsPersonAttend.ConfDate, qsConfDays.ConfDate

    if you run you will see NULLs in the qsPersonAttend.ConfDate (the missing dates)
    To see only the missing days, put IS NULL under qsPersonAttend.ConfDate.

  3. #3
    Ramtrap is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Dec 2016
    Posts
    62
    Quote Originally Posted by ranman256 View Post
    Q1, shows the persons and the days they attend conferences, qsPersonAttend
    Q2, shows the conferences and all the days, qsConfDays
    Q3, add in the 2 queries: qsPersonAttend and qsConfDays
    join the 2 on [ConfDate]
    make it an OUTER JOIN. Dbl-click the join line, set it to: ALL records in qsConfDays, some in qsPersonAttend
    bring down the dates from both
    qsPersonAttend.name, qsPersonAttend.ConfDate, qsConfDays.ConfDate

    if you run you will see NULLs in the qsPersonAttend.ConfDate (the missing dates)
    To see only the missing days, put IS NULL under qsPersonAttend.ConfDate.
    Thank you for responding! I'm trying to do what you advised, but I think I'm getting crossed up on the last part.

    Here is Q3, resulting from Q1 and Q2, as per above. You'll note that my Criteria statement is way off. Leaving it with a blanket IsNull statement generates an error, as expected, and I'm not entirely sure what the argument should be. (Note I am just using sample data and putting in ConferenceID = 1 and PersonID = 2. In my db, that person is going to days 1 and 3 of the conference, so I should be seeing day 2, but the whole thing (as run as above) yields NULL results for all fields (again because of my bad criteria)).

    Click image for larger version. 

Name:	Answer1.PNG 
Views:	13 
Size:	32.3 KB 
ID:	31358

    Thanks, again!

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    no, just (2 words):
    IS NULL


    oh, and add qsConfDays.CONFNAME to the query.

  5. #5
    Ramtrap is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Dec 2016
    Posts
    62
    Quote Originally Posted by ranman256 View Post
    no, just (2 words):
    IS NULL


    oh, and add qsConfDays.CONFNAME to the query.
    I got this to work, mostly. My misunderstanding for the Is Null vs IsNull, sorry!

    What it's doing now, however, is showing me every day that a person is not going to a conference, i.e. I have to re-state the Conference ID to re-tell the query that I want ONLY days this person is not attending THIS conference--not EVERY conference.

    As Is:
    Click image for larger version. 

Name:	Answer2a.PNG 
Views:	10 
Size:	4.4 KB 
ID:	31361Click image for larger version. 

Name:	Answer2B.PNG 
Views:	10 
Size:	4.8 KB 
ID:	31362

    Restating ConferenceID within Query:
    Click image for larger version. 

Name:	Answer3a.PNG 
Views:	9 
Size:	5.0 KB 
ID:	31363Click image for larger version. 

Name:	Answer3B.PNG 
Views:	9 
Size:	3.9 KB 
ID:	31364

    Is there a way to retain the ConferenceID field? (I changed the ConferenceDate to ConferenceID in my example, but the query search yield the same results, either way)

  6. #6
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    In your first post you had a criteria of ConferenceID. In the query qsConfDays you can add that criteria and it will carry thru to this query.

  7. #7
    Ramtrap is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Dec 2016
    Posts
    62
    Quote Originally Posted by aytee111 View Post
    In your first post you had a criteria of ConferenceID. In the query qsConfDays you can add that criteria and it will carry thru to this query.
    That was exactly it, thank you!

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

Similar Threads

  1. Look Up - show fewer options by matching criteria....?
    By synses in forum Database Design
    Replies: 3
    Last Post: 03-13-2017, 02:33 PM
  2. Replies: 4
    Last Post: 07-20-2016, 03:04 PM
  3. Count Combo Box Options
    By Emilee in forum Queries
    Replies: 4
    Last Post: 09-03-2015, 12:27 PM
  4. Combo Box Options
    By AnnWalls in forum Access
    Replies: 4
    Last Post: 05-06-2014, 06:06 PM
  5. Don't show lookup list options in report
    By dara in forum Reports
    Replies: 1
    Last Post: 02-17-2010, 10:26 PM

Tags for this Thread

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