Results 1 to 8 of 8
  1. #1
    rmcafee is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2011
    Posts
    4

    Converting a Code to Text


    I have a list of 30 codes that I want to covert to text. When the code is assigned to an entry, I would like it to display certain text.

    Here is an example of one of them.
    The code "01P" would equal the text "Accepts Responsibility".
    The code appears in the field labeled Comment1.
    New to Access so any help would be appreciated.

  2. #2
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    Do you have your Codes and the Descriptions in a Table?

  3. #3
    rmcafee is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2011
    Posts
    4
    Yes, the I have the Codes and Descriptions in a separate table/query.

  4. #4
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    Where is this happening? Is it on a Form?

    If it is on a Form [Data Entry?], you can provide the User with a Combo Box that has all the Codes [and descriptions if you want] showing and when the User selects a Code - the description can be displayed if that is what you need.

    If you post a few more details, I can give you a better answer.

  5. #5
    rmcafee is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2011
    Posts
    4
    I have all my data in a query. Some of the entries in the Comment1 field (column) have these various codes in them. I want the text to display instead, OR create another column that converts the code to the desired text. I've tried creating another column in the query and I've tried using something like Text Comment: IIF([Comment1]= "01P", "AcceptsResponsibility") but there are 30 of these and I can't figure our how to make so many work?

  6. #6
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    Ok. I think I understand now.

    You want to do all this IN a Query!

    Sorry i didn't GET that before!!

    I think you want something like this in the new field:

    Description: IIf([Code]="01P","Accepts Responsibility",IIf([Code]="02P","Second Description",IIf([Code]="03P","Third Description")))

    Each time you add a new IIF, you will have to add another closing parenthesis at the end.

    Let me know if this helps.

    I actually think you shouldn't be doing this.

    It looks like you should have all your Codes and their Descriptions in a separate Table.

    Once you have them in the Table, you don't need to write 30 IIF clauses in a query to match your 30 Codes and provide Descriptions. You can just get the descriptions from the Codes/Descriptions Table.

    Let me know if you have any questions about this.

  7. #7
    rmcafee is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2011
    Posts
    4
    Yes, when I tried doing all thirty it said it was too complex.
    Yes, I have the descriptions listed with the codes in another table/query for reference (they aren't matched with any data) but how do I get them to display the text if I only have the codes in my main data query. So I guess my question is how do I "get the descriptions from the Codes/Descriptions Table" to display from the codes listed in the second table?

    Another thing I should've mentioned. There are two Comment columns in the query Comment1 and Comment2, each column has the codes in them.

    I think I've gotten it to work just now by joining the properties to two queries that contain the Codes/Comments. I made a second copy of my Codes/Comments, linked one to Comment1 and the other to Comment2, went in to "Join Properties" on the link and got them to display everything.

    Looks like it works - Was this what your were thinking I should do instead of the IIF Clauses?

    Thanks for your help, you got me thinking of the alternatives I needed.

  8. #8
    TinaCa is offline Advanced Beginner
    Windows Vista Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    87
    I use this alot.

    I want to show the description of something from a code table but not the unique identifier for it. i.e. 1 blue, 2 red, 3 yellow. I have been creating a text box bound to the field that needs the code (like ColorID). Then when I create the combo box I hide column 1 (i.e. column count = 2, column widths 0,1). You know when you create a combo box you can tell it to Store the value in this field just select the field the text box is bound to .

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

Similar Threads

  1. querying and converting text to numbers
    By hollyh in forum Queries
    Replies: 2
    Last Post: 09-01-2011, 12:39 PM
  2. code for blank text ???
    By alex_raju in forum Access
    Replies: 1
    Last Post: 08-02-2011, 07:50 PM
  3. Code in combobox, code in text box
    By float in forum Forms
    Replies: 3
    Last Post: 09-29-2010, 07:12 AM
  4. Converting Option value to text
    By James3mc in forum Forms
    Replies: 4
    Last Post: 11-28-2009, 11:19 PM
  5. Converting all text input to lower case
    By aommaster in forum Forms
    Replies: 6
    Last Post: 08-05-2009, 05:43 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