Results 1 to 10 of 10
  1. #1
    MsAxes is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2021
    Posts
    100

    How to extract Alpha characters from a field?

    Hello all, I have a field [customer_no] that always has a mixture of numbers and letters. I need a field where it pulls the letters from the [customer_no] field. I don't know of an expression that could do that and my searches were of extracting numbers not letters.

    Any ideas?

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Can you give a few examples of the [customer_no] data
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    MsAxes is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2021
    Posts
    100
    Sure:

    Customer_no
    2131as5464asyypp1
    dg156464st84611dr
    1f2dr1gs5498rgsdg0
    f5123456sd3154548

    There is nothing that would help use the Left, Mid or Right expressions, all number and position is completely unique

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    5,008
    You would have to examine each character and add to another variable if alphabetic.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  5. #5
    Gicu's Avatar
    Gicu is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,122
    See this link:
    https://stackoverflow.com/questions/...numeric-string

    or with a bit of brute force and 10 nested Replace:
    Replace(Replace([Cust_No],"0",""),"1","").....

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  6. #6
    Clifford's Avatar
    Clifford is offline Novice
    Windows 10 Office 365
    Join Date
    Feb 2022
    Location
    California
    Posts
    1
    To extract alpha characters from a field, you can use the SUBSTRING function. The SUBSTRING function extracts a substring from a string.

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,963
    VBA does not have SUBSTRING function.

    If there will be only alpha and numbers, no punctuation/symbols, consider:

    Code:
    Function GetAlpha(strA)
    Dim strNew As String, x As IntegerFor x = 1 To Len(strA)
        If Not IsNumeric(Mid(strA, x, 1)) Then strNew = strNew & Mid(strA, x, 1)
    Next
    GetAlpha = strNew
    End Function
    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.

  8. #8
    Gicu's Avatar
    Gicu is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,122
    The link I provided includes number of versions for a custom VBA function, but if you do not want to rely on any programming you can try the nested Replace in a query.
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  9. #9
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,818
    Quote Originally Posted by Clifford View Post
    To extract alpha characters from a field, you can use the SUBSTRING function. The SUBSTRING function extracts a substring from a string.
    I'm curious to know what platform allows you to extract only alpha and every alpha character, from any position in a string.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  10. #10
    MsAxes is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2021
    Posts
    100
    All I appreciate your feedback and time. I didn't want to use the replace function so Gicu link and June7 VBA work for what I need.

    Thanks again

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

Similar Threads

  1. Extract characters from the String
    By soldat452002 in forum Access
    Replies: 12
    Last Post: 10-02-2018, 09:31 PM
  2. DMax +1 a field with alpha and numeric characters
    By beewerks in forum Programming
    Replies: 6
    Last Post: 02-12-2018, 05:06 PM
  3. Replies: 4
    Last Post: 02-24-2016, 04:43 PM
  4. Replies: 8
    Last Post: 10-09-2014, 01:31 AM
  5. Replies: 1
    Last Post: 03-09-2014, 06:30 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