Page 1 of 2 12 LastLast
Results 1 to 15 of 22
  1. #1
    newbiecoder is offline Advanced Beginner
    Windows 8 Access 2010 64bit
    Join Date
    May 2018
    Posts
    32

    Extract text when it matches specific format


    Hello! I have a table named tblOMNIDBValidationExtract and I need to extract anything formatted as "L00000000" from column RECORD_KEY.The length of each record varies. I would like to extract the data to another column named ACC_NO in the same table. Here are some examples:

    RECORD_KEY ACC_NO
    01A12345678201805252018050206807050 A12345678
    20180430A98765432 7 A98765432

    Any help would be greatly appreciated!

  2. #2
    Beetle is offline Unrelatable
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    Camp Swampy (Denver, CO)
    Posts
    207
    Does the ACC_NO always begin with A, or do you consider the first occurrence of any alpha character to be the beginning of the ACC_NO? Also, can there be occurrences of alpha characters that are not related to the ACC_NO?

  3. #3
    newbiecoder is offline Advanced Beginner
    Windows 8 Access 2010 64bit
    Join Date
    May 2018
    Posts
    32
    The ACC_NO can start with any letter and contains any 8 numbers for a total of 9 characters in length. There may be an additional random letter in the string, but it doesn’t fit the pattern

  4. #4
    newbiecoder is offline Advanced Beginner
    Windows 8 Access 2010 64bit
    Join Date
    May 2018
    Posts
    32
    Can this be done using the expression builder?

  5. #5
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    I think not. If the position of the first alpha was a constant, you could use the Mid function alone. Otherwise, it will require a combination of functions. Problem can be, will the alpha characters ever be D or E? They can be interpreted as scientific notation.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  6. #6
    newbiecoder is offline Advanced Beginner
    Windows 8 Access 2010 64bit
    Join Date
    May 2018
    Posts
    32
    Unfortunately, there is a possibility that there could be an E or a D in the string. For example, "010EKDPRAA4B49249000 201804309" should return B49249000.

  7. #7
    newbiecoder is offline Advanced Beginner
    Windows 8 Access 2010 64bit
    Join Date
    May 2018
    Posts
    32
    Currently, I am manually using Mid functions to pull the ACC_NO. There are three mid functions I am using. The ACC_NO starts at either the 3rd, 9th, or 12th space (i.e. =Mid(RECORD_KEY,3,9) / =Mid(RECORD_KEY,9,9) / =Mid(RECORD_KEY,12,9)...). Is there vba code that can run the mid function and if it returns a value formatted correctly ("L00000000") then it puts the value in column ACC_NO? However, if the mid value returns an incorrectly formatted string then it will move on the next mid function until it finds the proper function to use.

  8. #8
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    Can it be said that if you start from the right and go left that the 1st letter will always be the starting point?

  9. #9
    newbiecoder is offline Advanced Beginner
    Windows 8 Access 2010 64bit
    Join Date
    May 2018
    Posts
    32
    Quote Originally Posted by Micron View Post
    Can it be said that if you start from the right and go left that the 1st letter will always be the starting point?
    Unfortunately, the first letter read from the right isn’t always the starting point.

  10. #10
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    Then is there a constant at all? After reviewing the prior posts I can't tell. Maybe a sample set of one or two dozen would help us to discover a reliable pattern.

  11. #11
    newbiecoder is offline Advanced Beginner
    Windows 8 Access 2010 64bit
    Join Date
    May 2018
    Posts
    32
    Quote Originally Posted by Micron View Post
    Then is there a constant at all? After reviewing the prior posts I can't tell. Maybe a sample set of one or two dozen would help us to discover a reliable pattern.
    I apologize for any confusion. I am currently away from my computer that has the data for an hour or so, but here are some examples. There is only really one pattern and that’s “L00000000”:

    63628634A12345678538362 (Should show as A12345678)

    GEB12345678 (Should show as B12345678)

    EFG83632693C12345678EJ132 (Should show C12345678)

  12. #12
    newbiecoder is offline Advanced Beginner
    Windows 8 Access 2010 64bit
    Join Date
    May 2018
    Posts
    32
    In the third example you can see that there are two potential results just going off the formatting criteria (G83632693 and C12345678), however the correct result is the last possible combination of L000000000 which is C12345678.

  13. #13
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    PMFJI,

    How do you know that "C12345678" is the correct result?
    How is this determined?

  14. #14
    newbiecoder is offline Advanced Beginner
    Windows 8 Access 2010 64bit
    Join Date
    May 2018
    Posts
    32
    Quote Originally Posted by ssanfu View Post
    PMFJI,

    How do you know that "C12345678" is the correct result?
    How is this determined?
    It’s a system generated report that formats the data like that. I’m sure that “C12345678” is the correct result because we manually pull the substring and compare it to another list later on in our process. It’s determined by being the last possible combination of L00000000 in the string.

  15. #15
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    So the approach might be to start from the right and in a loop For i = 1 To Len(str) where str is the value being examined, increment counter n looking for 8 successive integers. If not successful at any point, start n at 0 again and continue. When 8 are found, go left 1 more character and extract a total of 9 IF that character is alpha. ??
    If 9th isn't alpha then carry on until 1 alpha is found and extract 9 from there??

    EDIT: if that is accurate, you should post a db with a table of test data. It should contain a field for storing the derived value as well.
    I don't mind helping out with complex problems, but I believe it's incumbent upon the poster to do some of the work.

    PMFJI,
    I always enjoy your input. Keep on jumping in

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 10
    Last Post: 04-04-2018, 10:36 AM
  2. Extract specific text from very long string
    By csmith in forum Queries
    Replies: 24
    Last Post: 03-03-2017, 09:25 AM
  3. Replies: 7
    Last Post: 02-29-2016, 06:13 PM
  4. Replies: 2
    Last Post: 10-21-2015, 12:00 PM
  5. Extract Specific Data from Access
    By iamstupid in forum Access
    Replies: 1
    Last Post: 05-26-2011, 12:58 AM

Tags for this Thread

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