Results 1 to 7 of 7
  1. #1
    dakpluto is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    18

    Removing occasional last letter

    I have been using the following expression in one of my databases for a while now:



    New Rate Price: Right([Fortlauderdale_target.Rate_Code],4)/100

    This is to pull the rate out of a code that looks like the following:

    O0135
    O0138
    S0363
    etc.

    However, with some changes in the company, I now occasionally get the following:
    S0418D
    O0135D
    S0616D

    it's random on when that trailing D will appear. So how do I adjust my original expression to remove the D when it appears?

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    You can use the RIGHT function to check the right-most characters to see if it is a number (use the ISNUMERIC function, see: http://www.techonthenet.com/access/f.../isnumeric.php).

    That should give you the missing piece to do what you need. If you run into trouble putting it all together, post back to this thread.

  3. #3
    dakpluto is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    18
    Gonna need some help on how to include it, but does sound like the right idea. I'm sure it's gonna incorporate some if statements, maybe some nested if statements, but not sure how to throw it all together.

  4. #4
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    New Rate Price: IIf(IsNumeric(Right([Rate_Code],1)),Right([Rate_Code],4),Left(Right([Rate_Code],5),4))/100

  5. #5
    dakpluto is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    18
    And after all of that....it dawned upon me there is a way 500 thousand times easier....

    New Rate Price: Mid([Fortlauderdale_target_20130429.Rate_Code],2,4)/100

    /facepalm

    Dunno why I didn't think of it earlier.

  6. #6
    dakpluto is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    18
    Quote Originally Posted by JoeM View Post
    New Rate Price: IIf(IsNumeric(Right([Rate_Code],1)),Right([Rate_Code],4),Left(Right([Rate_Code],5),4))/100
    I tested this also in case I ever need it for the future, works perfectly also. Thanks Joe (o.o)b

  7. #7
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Yes, that would be easier. I didn't want to assume that you always had just a one-letter prefix. If you do, that simplified one will work. If it could be more than one, then the one I posted will work.

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

Similar Threads

  1. Auto increment Letter
    By andy-29 in forum Access
    Replies: 4
    Last Post: 11-08-2012, 05:23 PM
  2. Replies: 4
    Last Post: 09-18-2012, 05:07 AM
  3. hide autonumber letter..
    By alex_raju in forum Forms
    Replies: 0
    Last Post: 07-20-2011, 12:44 AM
  4. filter name by letter
    By kbremner in forum Programming
    Replies: 3
    Last Post: 10-30-2010, 07:48 PM
  5. From letter from a report
    By LANCE in forum Reports
    Replies: 4
    Last Post: 07-04-2009, 09:32 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