Results 1 to 4 of 4
  1. #1
    rankenory is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    May 2012
    Posts
    3

    how do you remove all text before first number in a text field

    I haven't found a reference to this problem anywhere on the web, much less a solution. (I'm hoping there's a solution for doing this in query design view, or, if not, SQL view, but I'm certainly open to finally learning something about module creation, if that's the best way around this. I've never written a module before, so I'm not even sure how to call for it in the query.)

    The problem: I have a field that starts with unwanted text before the first number appears. I only want to keep the part starting with the first number.

    I realize that a "number" in this text field is seen as text to Access, and I know that Chr(48) through Chr(57) is how Access would recognize these ASCII number characters. I am not aware of another way to represent all of these characters with something like a # sign in query design (tried and failed), so I'm guessing I'll have to reference them using Chr.

    The field: The field is called "Location Address", and it contains street addresses that follow text relating to the type of facility at the address.

    Examples of data records in the field:
    Fitten Hall 855 McMillian Street, NW
    Baker Building 939 Dalney Street, NW
    Barnes and Noble 48 Fifth Street, NW

    How I want the addresses to read in my query result (from which I will make a new table):
    855 McMillian Street, NW
    939 Dalney Street, NW
    48 Fifth Street, NW

    I tried to use InStr, Len and Right functions to identify the position of the first number and remove everything before it, but I only know how to ask for one number in the InStr, for instance:
    [code]: Address starting with number 8: Right([Location Address],Len([Location Address])-InStr(4,[Location Address],"8")+1)

    This does return Fitten Residence Hall 855 McMillian Street, NW as 855 McMillan Street, but does not work with 939 Dalney Street. Worse yet, 48 Fifth Street becomes 8 Fifth Street!



    I would love to see a solution to this. My need to resolve this isn't great, but at this point I just want to know how it could be solved, because I spent hours researching this with no solution.

    Thanks

  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
    The only way that comes to mind is a custom function that accepts the entire string as an input and outputs the desired string. It would step through the characters looking for a number (For/Next loop). Once it finds one, you use the position with InStr() to return the desired string.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    rankenory is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    May 2012
    Posts
    3

    solution?

    Can anyone provide an answer involving specific formulas or code that would work with this type of problem?

    Quote Originally Posted by pbaldy View Post
    The only way that comes to mind is a custom function that accepts the entire string as an input and outputs the desired string. It would step through the characters looking for a number (For/Next loop). Once it finds one, you use the position with InStr() to return the desired string.

  4. #4
    rankenory is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    May 2012
    Posts
    3
    Looking at Paul's reply, I guess it just suprises me that this problem would require a solution that complex, since we know that the set of characters we are interested in have ASCII representations that can be referred to. I was interested to know if there are formulas or combinations of formulas that would do that.

    Quote Originally Posted by rankenory View Post
    Can anyone provide an answer involving specific formulas or code that would work with this type of problem?

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

Similar Threads

  1. Replies: 2
    Last Post: 03-30-2012, 07:39 AM
  2. Splitting a number field across 4 text boxes
    By R_Badger in forum Reports
    Replies: 1
    Last Post: 02-06-2012, 06:12 AM
  3. Field switching from Number format to Text
    By COforlife in forum Queries
    Replies: 1
    Last Post: 11-10-2009, 03:23 PM
  4. Replies: 1
    Last Post: 10-09-2008, 04:48 AM
  5. Concatenate two fields (text & number) for key field
    By Larry Elfenbein in forum Forms
    Replies: 2
    Last Post: 11-10-2005, 07:45 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