Results 1 to 5 of 5
  1. #1
    jnrussell is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Feb 2014
    Posts
    17

    How can I use a query to compare single letter in table to the corresponding word?

    I thought this would be easy, but I've been trying various things and can't figure it out. In of of my tables there is a column called "Type". In the Type field there are entries like "F", "I", "R", etc. On a report I want those entries to display the corresponding word that matches it: "F" would be "FISH", "I" would be "INVERTEBRATES", "R" would be "REPTILES", etc.



    How can I create a query, or create an expression in the main query for the report that will make this conversion?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Options:

    1. If there are only the 3 Types, use an expression:
    Switch([Type]="F",FISH", [Type]="I","INVERTEBRATES", [Type]="R","REPTILES")

    2. If you have more than 3 Types or want greater flexibility to add more, create a table of the Type codes and descriptors, include this table in query by joining on the common Type code fields.

    Consider saving the full text descriptor instead of just the single letter code. Then no need to join tables in query. Can still use a table as source for combobox.
    Last edited by June7; 02-09-2014 at 11:08 AM.
    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
    jnrussell is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Feb 2014
    Posts
    17
    I knew it was simple! I've actually used method 2 many times before. Don't know why I couldn't think of it in this case. However, I'm glad I asked because I wasn't familiar with method 1. I like it and am going to try it here. Thank you so much.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Ooops! I should have used Switch instead of Choose. I edited the post.

    Can be used with more than 3 elements.
    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
    jnrussell is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Feb 2014
    Posts
    17
    Thanks. You posted the correction before I had time to try it out, so it all worked out. I used Switch and it worked perfectly. Thanks

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

Similar Threads

  1. Replies: 2
    Last Post: 11-05-2013, 02:25 PM
  2. Making sure first letter of word is Upper case.
    By rzw0wr in forum Programming
    Replies: 1
    Last Post: 06-21-2013, 08:31 PM
  3. Searching for a single word in all table
    By rielcas in forum Access
    Replies: 1
    Last Post: 06-19-2013, 06:28 AM
  4. Replies: 4
    Last Post: 09-18-2012, 05:07 AM
  5. Force First Letter of every word to UPPERCASE (no StrConv)
    By yohansetiawan in forum Programming
    Replies: 13
    Last Post: 03-22-2012, 01:58 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