Results 1 to 12 of 12
  1. #1
    mp3909 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    154

    Populating a combo box but depends on the result of SQL

    Hello,



    What I am trying to achieve?

    I have this form.

    Click image for larger version. 

Name:	Capture1.PNG 
Views:	29 
Size:	41.5 KB 
ID:	52299

    The user needs to select the next cdd status by selecting a value from the combo box highlighted in yellow in the snapshot.

    Currently, the combo box shows all possible values for the cdd status as you can see from the below snapshot.

    Click image for larger version. 

Name:	Capture2.png 
Views:	28 
Size:	51.1 KB 
ID:	52300

    I don't want that, I only want it to show only "Completed" because if you look at the Audit Trail of that Client in the snapshot, you can see the latest status (i.e. the one without an EndDate) is Fully Remediated and the next stage after Fully Remediated is Completed.
    That is just one example. If the latest status was say "With Analyst" then the next possible stage is "With RM" or "With QC" so the dropdown combo box should show only 2 values "With RM" or "With QC" as the only possible values to select.

    Getting the latest CDD Status is not difficult, I can use this SQL but not sure how to reference the caseID textbox that lives in my main form which contains the unique identifier for the client.

    Click image for larger version. 

Name:	Capture3.PNG 
Views:	26 
Size:	5.8 KB 
ID:	52301

    I guess I need to use a Query for this SQL right?

    Then I need to write an if-else logic to display all possible scenarios as follows:

    if SQL returns = "With Analyst" then
    Combo Box for CDDStatus = should show "With RM" or "With QC"
    else if SQL returns = "Fully Remediated" then
    Combo Box for CDDStatus = should show "Completed"
    else if SQL returns = "With QC" then
    Combo Box for CDDStatus = should show "With FCT" or "Pending CIF Closure"
    end if


    Will anyone know how I can accomplish this please?
    Thank you in advance!!
    Attached Thumbnails Attached Thumbnails Capture1.PNG  

  2. #2
    mp3909 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    154
    attached is the db
    Attached Files Attached Files

  3. #3
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,574
    You can directly reference the form control.
    You can set a TempVar to the CaseID and use that in the criteria.

    I tended to use the TempVar, as I had an aversion in tying queries to forms, mainly so I could use them elsewhere, so wherever I needed that query all I need to do was set a Tempvar(s).

    I would probably have those added descriptions in the table for those entries, so QC would appear twice, once for each description.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  4. #4
    xps35's Avatar
    xps35 is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jun 2022
    Location
    Schiedam, NL
    Posts
    300
    Quote Originally Posted by mp3909 View Post
    you can see the latest status (i.e. the one without an EndDate) is Fully Remediated and the next stage after Fully Remediated is Completed.
    You know that. How is Access supposed to know that?
    Groeten,

    Peter

  5. #5
    mp3909 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    154
    Quote Originally Posted by xps35 View Post
    You know that. How is Access supposed to know that?
    That's why I have outlined a set of logical operations using if-else will be required or something similar.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Code-based logic can certainly work, but I'd prefer something in a table. That way if/when you get new/different steps, you can incorporate them in the table. You don't want to have to mess with code just because you get a new step. I don't know enough about how this process works to offer a specific recommendation on that table's design.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    xps35's Avatar
    xps35 is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jun 2022
    Location
    Schiedam, NL
    Posts
    300
    I agree with Paul and that is why I asked the question. These rules are data so need to be stored in tables. You can easily handle changes in rules. Populating your combobox is also easy; write a SQL to extract the statuses that match the rule.
    Groeten,

    Peter

  8. #8
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,941

    Smile

    1 - change the linkmaster property of the subform to the name of your listbox
    2 - I would add another column to your departments to identify the order for 'what comes next'. Based on the information provided it might be

    Group Stage Current CDD Status Parent
    FCO Not Started
    FCO With Analyst
    FCO With QC With Analyst
    BUSINESS With RM With Analyst
    SECOND LINE With FCT
    BUSINESS Pending CIF Closure
    FCO CDD Completed
    BUSINESS Pending System Update
    FCO Fully Remediated
    FCO Descoped

  9. #9
    mp3909 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    154
    Quote Originally Posted by CJ_London View Post
    1 - change the linkmaster property of the subform to the name of your listbox
    2 - I would add another column to your departments to identify the order for 'what comes next'. Based on the information provided it might be

    Group Stage Current CDD Status Parent
    FCO Not Started
    FCO With Analyst
    FCO With QC With Analyst
    BUSINESS With RM With Analyst
    SECOND LINE With FCT
    BUSINESS Pending CIF Closure
    FCO CDD Completed
    BUSINESS Pending System Update
    FCO Fully Remediated
    FCO Descoped

    Why are you suggesting to change the link master property in subform? The subform is fine. My issue is nothing to do with subform

  10. #10
    CarlettoFed is offline Competent Performer
    Windows 7 64bit Access 2013 32bit
    Join Date
    Dec 2019
    Posts
    274
    See if it works.
    Database271.zip

  11. #11
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,941
    Why are you suggesting to change the link master property in subform?
    I said ‘of’ the subform. And because you don’t need the other control

  12. #12
    mp3909 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    154
    Quote Originally Posted by Welshgasman View Post
    You can directly reference the form control.
    You can set a TempVar to the CaseID and use that in the criteria.

    I tended to use the TempVar, as I had an aversion in tying queries to forms, mainly so I could use them elsewhere, so wherever I needed that query all I need to do was set a Tempvar(s).

    I would probably have those added descriptions in the table for those entries, so QC would appear twice, once for each description.

    Hi Welshgasman,

    I went with your suggestion in using TempVar and used that in the criteria.
    All good, everything working as expected now so thank you!

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

Similar Threads

  1. Replies: 3
    Last Post: 05-30-2014, 12:34 AM
  2. Change Photo Depends on combo box value
    By mr_right in forum Access
    Replies: 3
    Last Post: 05-30-2013, 01:48 AM
  3. Replies: 2
    Last Post: 08-16-2012, 10:02 PM
  4. One combo depends on another doesent work
    By scifo_dk in forum Forms
    Replies: 2
    Last Post: 11-26-2010, 04:25 AM
  5. Replies: 1
    Last Post: 10-22-2009, 03:32 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