Results 1 to 10 of 10
  1. #1
    AllenBeverly is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2019
    Posts
    5

    getting rid of characters between numbers

    I am dealing with account numbers that need to be matched when I upload into our system.


    The numbers are in text format and are received from external sources where you can't
    count on the same format from month to month.

    What I am really trying to do is change 12345_6789 or 12345-6789 to 123456789 so I can
    have a consistent account number to match to when I upload.

    A resolution to this would be fantastic!

    Thanks!
    AB

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    For one or two I'd use the Replace() function to replace the undesired character with nothing (""). If there are many, I might use a function that looped through the characters and only let the desired characters through.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,725
    I agree with Paul if that's the range of potential "account numbers" you receive. A function and loop may be needed if you can get other punctuation, alphabetic or extended ascii chars.

  4. #4
    AllenBeverly is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2019
    Posts
    5
    How would that look in code?
    One problem is that there is no consistent standard.
    I want something that will account for both examples.

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Here's my code template, adjust as desired.

    Code:
    Public Function ReplaceSpecial(varInput As Variant) As Variant
      Dim strString               As String
      Dim x                       As Integer
      For x = 1 To Len(varInput)
        Select Case Asc(Mid(varInput, x, 1))
          '32 = space, 47 = /, 48-57 = 0-9, 65-90 = A-Z, 97-122 = a-z
          Case 32, 47 To 57, 65 To 90, 97 To 122
            strString = strString & Mid(varInput, x, 1)
        End Select
      Next x
      ReplaceSpecial = strString
    End Function
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    AllenBeverly is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2019
    Posts
    5
    Thanks for your quick response.
    I need to digest this for a while.

    Even though I have been using Access for over 20yrs
    now I think I need to explain how I use it. I am not aware
    of anyone who uses it for what I do.

    I am tied up right now at
    work so I will respond sometime tomorrow.

    Again I appreciate your quick response.

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    No problem, and welcome to the site by the way!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    AllenBeverly is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2019
    Posts
    5
    The way I use access right now is as a workbench for the data system that I am working on.
    My current system is cloud based so I also use a tool that allows me to access the tables in
    the system similar to if I was accessing from a sql server.

    I export the necessary data into different access databases depending on the data
    (transactions, customers, users, etc.) So using Access I am creating my own sql server.

    This allows me to accomplish things that would not be possible any other way that I am
    aware of which is not important to my current problem. I do not use access to set up for
    other users anymore and am several years away from any coding I have done in the past.

    I was not happy with the amount of changes MS made from xp to current versions so I have
    only used it for working with data systems and find it a tool that is invaluable for what I do.

    As for the function you wrote I understand it but am not sure how to use it for what I am
    trying to do.

    I would appreciate any additional help you could give to help me "see the light".

    Thanks!
    AB

  9. #9
    AllenBeverly is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2019
    Posts
    5
    I think I am going to handle this by adjusting the code in the data system
    instead of the other way around.

    Thanks for your help but I should have thought of this before.
    But the good thing is it introduced me to this forum and that's a positive.

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Sorry, late start due to snow. Glad you have a solution. To use the function you'd incorporate it into whatever method you use to import data (or to update it after import). Shouldn't be hard if you go back that way.
    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: 5
    Last Post: 05-02-2016, 12:41 PM
  2. Replies: 8
    Last Post: 03-10-2014, 11:47 AM
  3. Replies: 9
    Last Post: 02-11-2013, 03:09 PM
  4. Replies: 1
    Last Post: 11-29-2011, 08:43 AM
  5. Setting a field to only accept text characters, not numbers
    By USAFA2012 in forum Database Design
    Replies: 2
    Last Post: 03-09-2010, 12:37 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