Results 1 to 11 of 11
  1. #1
    SunTop is offline Advanced Beginner
    Windows 8 Access 2016
    Join Date
    Aug 2016
    Posts
    93

    combo box value display


    How to display values in a combo box based on a certain criteria ? for example I want to display some values if the current date is after a certain date and display other values if the current date is before a certain date ?

  2. #2
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,933
    you need to modify the rowsource on some event - might be the form open event, might be the after update event of the control that sets the 'certain' date. without more information - your current rowsource, what determines which records to show, how the 'certain' date is determined etc, it is not possible to be more specific

  3. #3
    SunTop is offline Advanced Beginner
    Windows 8 Access 2016
    Join Date
    Aug 2016
    Posts
    93
    Thanks for your reply Ajax

    I have a form in my database that lists the details of a work order (location, type, issue date, expiry date). The combo box picks values from another table (completed, pending, late). I want the combo box to display only completed or pending when the current date is before the expiry date and when the current date is after the expiry date then I want the combo box to display all the values (pending, completed or late).

  4. #4
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,933
    ? details of your rowsource - i.e. the sql you are currently using and details of the underlying table it is querying

  5. #5
    SunTop is offline Advanced Beginner
    Windows 8 Access 2016
    Join Date
    Aug 2016
    Posts
    93
    The record source of the form is a query, the location and type fields are picked from a table and the issue date and expiry date is picked from another table. These two tables are not related directly, rather they are joined by a “mid” table.

    Edit: the first table has another field (WorkOrderStatus), this field is left empty when the record is first created, this field is a combo box and it picks its values from a third table that is joined to the first table (I could have used a list of values here also), in this field I want the user to pick either completed, pending or late if the current date is after the expiry date, but if the current date is before the expiry date then I want the combo box only to display pending or completed.

  6. #6
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,933
    hmm, don't think I can help more than my suggestion in post #2. If you cannot provide the detail requested, I don't see how I can provide a more detailed suggestion. Solution might be some vba code of some sort, or it might be in the sql, or it might be two different queries - could be anything really.

  7. #7
    SunTop is offline Advanced Beginner
    Windows 8 Access 2016
    Join Date
    Aug 2016
    Posts
    93
    Thanks for your reply Ajax

    would it help if I provide a sample database ?

  8. #8
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,933
    can if you want - remove any sensitive data, compact the db then zip it

  9. #9
    SunTop is offline Advanced Beginner
    Windows 8 Access 2016
    Join Date
    Aug 2016
    Posts
    93
    Thanks for you reply Ajax

    Here is the sample database

    The status combo box in the followup form has three options (pending, completed, late) if the expiry date is after the current date, I need the status combo box to display (pending or completed), if the expiry date is before the current date, I need the status combo box to display all three options
    Attached Files Attached Files

  10. #10
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,933
    For future reference you are talking about cascading combos - and in this case on a continuous form.

    1. You need an additional column in your status table to identify those records to appear after the expiry date. called say DisplayAfter as a yes/no field and set to true if required to display after
    2. Once you have done that, in the Status on enter event put

    status.rowsource="SELECT [Status].[ID], [Status].[Status] FROM Status WHERE ExpiryDate>Date()=DisplayAfter"

    3. then in the Status on exit event put

    status.rowsource="SELECT [Status].[ID], [Status].[Status] FROM Status"

  11. #11
    SunTop is offline Advanced Beginner
    Windows 8 Access 2016
    Join Date
    Aug 2016
    Posts
    93
    It worked perfectly !
    Thank you Sir for your time and patience

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

Similar Threads

  1. Replies: 1
    Last Post: 02-06-2016, 05:33 AM
  2. Display value in combo box
    By jjmclell in forum Forms
    Replies: 4
    Last Post: 07-09-2015, 08:45 AM
  3. Combo Box display
    By RayMilhon in forum Forms
    Replies: 1
    Last Post: 07-06-2015, 05:10 PM
  4. Combo box display
    By crowegreg in forum Forms
    Replies: 3
    Last Post: 07-13-2012, 12:24 PM
  5. Combo Box Display
    By ssaucedo in forum Reports
    Replies: 17
    Last Post: 08-10-2009, 05:52 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