Results 1 to 10 of 10
  1. #1
    samye is offline Novice
    Windows 10 Office 365
    Join Date
    Oct 2022
    Posts
    9

    Question Decode Table Deprecate Values

    Hello,

    I have several decode tables with values that I do not want used anymore but I want the value to remain on the record.

    For example, the application has a Building table that contains Building information, name, address, etc. It has a relationship with a Status table that contains the decode of the StatusCode. The values are SOLD, LEASED, DEMOLISHED, DUPLICATE. Duplicate is used when a record was created in error. On the Entry Form the Status is a drop-down that contains the fore mentioned values. I don't want the users to see DUPLICATE because those records are updated on the back-end. There is a query associated with the drop-down box. I added a field, StatusDeprecated as a YES/NO field to the Status table and modified the query to not show if YES/NO is true.



    This works, except if I bring a record up that has a status of DUPLICATE the drop-down is blank.

    Please recommend the proper way to do this.

    Caveat, this system was written in 1996, so rather than delete a record that was duplicated, they chose to keep it. I'm just trying to clean the data up and create some rules around the current processes.

    Thank you,
    Carol

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Are you saving text or a foreign key of lookup table Status?

    The dropdown list should not be blank.

    Review this question about cascading/dependent/conditional combobox https://stackoverflow.com/questions/...t-show-its-val
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    samye is offline Novice
    Windows 10 Office 365
    Join Date
    Oct 2022
    Posts
    9

    Reply

    Hello,

    The foreign key is being stored. The dropdown is not blank, the first entry is blank if the value has been set to deprecated. Here are some screen shots:

    Here is the table:
    Click image for larger version. 

Name:	1.png 
Views:	18 
Size:	43.1 KB 
ID:	50802




    Here is the form with the value:

    Click image for larger version. 

Name:	2.png 
Views:	18 
Size:	19.3 KB 
ID:	50803


    Here is the query:

    SELECT lutBuildingStatus.StatusID, lutBuildingStatus.StatusValue, lutBuildingStatus.StatusDeprecated
    FROM lutBuildingStatus
    WHERE (((lutBuildingStatus.StatusDeprecated)=No))
    ORDER BY lutBuildingStatus.StatusValue;





    Here I set DUPLICATE to deprecated:

    Click image for larger version. 

Name:	3.png 
Views:	18 
Size:	45.3 KB 
ID:	50804


    Then I access the form and the field is blank because the query isn't presenting it. I don't want the query to present any deprecated values but I want the database value to show.

    Click image for larger version. 

Name:	last.png 
Views:	18 
Size:	71.3 KB 
ID:	50805




    Is there a setting or event or combination that I need to use first?




    Thank you.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Did you review the link I posted earlier?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,938
    Here is how I handled this.
    Instead of just a boolean flag, I also had a DateDeactivated. In hindsight, that date field is all that is needed.

    That way I still could see the caseworker for an old case, yet when I went to select a caseworker for a new case, only current ones were in the combo.

    Code:
    Perhaps you can adapt for your situation?
    SELECT Lookups.ID, Lookups.Data
    FROM Lookups
    WHERE (((Lookups.DataType)='Email') AND ((nz([Lookups].[DeActiveDate],Date()))>=#8/1/2019#))
    ORDER BY Lookups.Data;
    I picked an arbitary date just before the first person left.

    HTH

    It is also a good few years since I implemented this.
    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

  6. #6
    samye is offline Novice
    Windows 10 Office 365
    Join Date
    Oct 2022
    Posts
    9
    Hello,
    Yes, I reviewed the post. It is not the same as what I am doing. I do not have two combo boxes but one and I am using a form not a datasheet view. I kind of understand what the post is explaining but it will not work for me. It is cludgy programming. To layer a box on top of another box is not a good solution but thank you for the post.

  7. #7
    samye is offline Novice
    Windows 10 Office 365
    Join Date
    Oct 2022
    Posts
    9
    Hello,
    Thank you for your reply. I'm afraid the above will give me the same results. The issue is the query on the combo is discarding any records that are deprecated, whether that is with a date or a yes/no, so the field appears blank. I was thinking I would need an event or maybe adjust the query of the form.
    Kind Regards,
    Carol

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Doesn't have to be two comboboxes. You have one combobox with RowSource that is dependent on value in another field/control (textbox or combobox or otherwise). Referenced link still applies.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    samye is offline Novice
    Windows 10 Office 365
    Join Date
    Oct 2022
    Posts
    9
    Hello,
    I found my answer here: https://www.access-programmers.co.uk...source.295349/

    This uses the GotFocus and LostFocus events. The combo box on the form has a query assigned to display the description based on the decode table. When I click the drop down the Got Focus executes a sql statement to display the values that are not deprecated. When the focus is lost the query runs again.

    So far, it works.

    Thank you all for your replies.

  10. #10
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Basically what was described in the link referenced in post 2.
    Could have code that only filters second combobox when it gets focus then restore the full list when loses focus. Users will still see data briefly disappear from other records and may find distracting at first but will learn to disregard.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Decode PDF Metadata
    By kd2017 in forum Misc
    Replies: 5
    Last Post: 11-11-2022, 04:49 AM
  2. Decode an IIf query
    By Charlie24 in forum Queries
    Replies: 5
    Last Post: 05-06-2022, 02:12 PM
  3. Can someone decode this code in layman's terms
    By ItsJustMe3377 in forum Modules
    Replies: 3
    Last Post: 10-19-2017, 11:16 AM
  4. decode expression question
    By redhonda9834 in forum Queries
    Replies: 5
    Last Post: 11-24-2015, 10:13 AM
  5. how to decode a string of numbers
    By cjlieber in forum Programming
    Replies: 4
    Last Post: 04-16-2012, 06:50 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