Results 1 to 8 of 8
  1. #1
    Darth_Elicious is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Apr 2017
    Posts
    11

    Replacing Numbers with Letters

    Hello all,



    I am trying to make a system to label photos I take in the field for my job. The numbers follow the format "[Name]_[Letter] Facing [Direction]", or something like "XX12345_a Facing North".

    I already asked about getting the numbers to line up correctly, so I can get the names to follow a _1, _2, _3... format, which works great (https://www.accessforums.net/showthr...027#post354027)

    The problem is sometimes clients want it labeled with letters instead of numbers. I have found a way to use REPLACE to get the result I want, like this:

    Photo Resource Number Letter
    1233 XX12234 1 a
    1234 XX12234 2 b
    1235 XX12234 3 c
    1236 XX12234 4 d
    1237 XX12356 1 a
    1238 XX12356 2 b
    1239 XX12677 1 a

    Here is the formula I have:

    (REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(R EPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REP LACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLA CE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE (REPLACE([N],"10","j"),11","k"),"12","l"),"13","m"),"14","n"), "15","o"),"16","p"),"17","q"),"18","r"),"19","s"), "20","t"),"21","u"),"22","v"),"23","w"),"24","x"), "25","y"),"26","z"),"1","a"),"2","b"),"3","c"),"4" ,"d"),"5","e"),"6","f"),"7","g"),"8","h"),"9","i") )

    That's 26 total REPLACES for the alphabet . The problem is it slows access WAAAAAY down when it loads. Is there a less demanding way to accomplish this?

    Thanks!

  2. #2
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    Why not create a table with 1-26 and a-z

    Then link that table to your current one joining in the 3rd column


    Sent from my iPhone using Tapatalk

  3. #3
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Or

    Chr(96 + [N])
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    Darth_Elicious is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Apr 2017
    Posts
    11
    Wow, that was easy. THANKS!!

  5. #5
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Whoever's solution you used was happy to help.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    Ditto!! [emoji6]


    Sent from my iPhone using Tapatalk

  7. #7
    Darth_Elicious is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Apr 2017
    Posts
    11
    I used yours Pbaldy, but Andy's was a good way too. Thanks again! If it's not too much trouble, out of curiosity, can you explain to me what the Chr(96 + [N]) command is actually doing? That is a very simple line for such a seemingly complex function.

    Thank you!

  8. #8
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Andy recommended a table, which normally would be a good solution, but in this case there already is one (in a manner of speaking):

    https://www.techonthenet.com/ascii/chart.php

    97 is the decimal value for "a", so my solution simply adds your number to 96 and converts the result to the ascii code.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 2
    Last Post: 06-05-2015, 01:07 PM
  2. mix of letters and numbers on the form
    By iscinar in forum Forms
    Replies: 15
    Last Post: 10-20-2013, 06:11 AM
  3. Add letters to sequential numbers
    By bassplayer79 in forum Programming
    Replies: 29
    Last Post: 09-12-2013, 04:20 AM
  4. IIF with numbers and letters
    By hzrdc2 in forum Queries
    Replies: 2
    Last Post: 03-28-2013, 07:29 AM
  5. Removing all letters or all numbers from string
    By Hayley_sql in forum Programming
    Replies: 2
    Last Post: 09-16-2009, 02:01 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