Results 1 to 2 of 2
  1. #1
    messier is offline Novice
    Windows 10 Access 2016
    Join Date
    Mar 2020
    Posts
    18

    Extract a String of 9 and or 8 digits

    Hi there,


    i have a column called Remarks with example below:

    REMARKS
    -----------------
    A#457895674:ABC
    A#456735674,Affff
    A#70673564,Afeefff
    AY#126734674;ABC
    AA#456235674,ABC

    As you can see, the numbers may not always start on the 3rd Char and it may end off with a "," ":" or ";"
    how do i just pull the numbers out? (Could be 8 or 9 digits.)

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,936
    perhaps something like

    val(mid(myfield,instr(myfield,"#")))

    e.g.
    ?val(mid("A#457895674:ABC",instr("A#457895674:ABC" ,"#")+1))
    457895674
    ?val(mid("A#70673564,Afeefff",instr("A#70673564,Af eefff","#")+1))
    70673564
    ?val(mid("AY#126734674;ABC",instr("AY#126734674;AB C","#")+1))
    126734674

    note that if the number can start with a zero - then it is not a number, it is a string

    ?val(mid("AY#026734674;ABC",instr("AY#026734674;AB C","#")+1))
    26734674
    so depends if you mean a number

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

Similar Threads

  1. vba to extract four numbers from a string
    By mainerain in forum Programming
    Replies: 3
    Last Post: 04-16-2020, 06:43 PM
  2. Extract date from a string
    By stalk in forum Queries
    Replies: 3
    Last Post: 04-10-2020, 08:35 AM
  3. Extract data from string
    By johnny51981 in forum Queries
    Replies: 20
    Last Post: 06-22-2015, 02:44 PM
  4. Extract part of string
    By Fais in forum Access
    Replies: 5
    Last Post: 08-06-2014, 04:46 PM
  5. Extract Value from Variable in String
    By nguyenak in forum Programming
    Replies: 3
    Last Post: 05-24-2012, 03:50 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