Results 1 to 5 of 5
  1. #1
    gregu710 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2012
    Location
    Frederick, CO (near Longmont and Boulder)
    Posts
    40

    Can I use a Find expression to parse data in a Table

    Hi, I've got a Table with a string of data delimited by an "*". The first part of the string before the "*" can be variable in length, so if I use a LEFT expression to break apart the 2 parts of the string on each side of the "*", my results are incorrect. In MS Excel, I can use the following formula to solve the problem:


    =LEFT(B6,(FIND("*",B6)))

    You are just substituting the number of positions with a Find command that looks for the "*", and returns anything left of the "*". Unfortunately, the brilliant programmers at Microsoft, once again, don't have an Excel function in Access. Any ideas on how to recreate that functionality in a table in Access?

  2. #2
    John_G is offline VIP
    Windows XP Access 2003
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    You can use the instr() function. Instr returns the first occurrance of one string within another.

    Example - if MyString = "ABCD*EFGH", then Instr(MyString,"*") = 5

    From that, left(MyString,Instr(MyString,"*")-1) = "ABCD"

    John

  3. #3
    gregu710 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2012
    Location
    Frederick, CO (near Longmont and Boulder)
    Posts
    40
    Quote Originally Posted by John_G View Post
    You can use the instr() function. Instr returns the first occurrance of one string within another.

    Example - if MyString = "ABCD*EFGH", then Instr(MyString,"*") = 5

    From that, left(MyString,Instr(MyString,"*")-1) = "ABCD"

    John
    Thanks John, got it worked out where I'm not getting synax errors or anything, but it keeps giving me the following result: #Type! Does it matter if the data I am seeking on the left side of the "*" is all alpha, all numeric or alpha-numeric (or a mix of alpha-numeric and numeric)?

  4. #4
    John_G is offline VIP
    Windows XP Access 2003
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    HI -

    If you are using it as a string, then no, there should not be an issue. In what context are you getting the #Type error?

    John

  5. #5
    gregu710 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2012
    Location
    Frederick, CO (near Longmont and Boulder)
    Posts
    40
    never mind John, got it solved, and even tweaked it to cut off the "*".... Thanks again! To clarify, I didn't have the start position listed before the MyString in the statement Instr(Mystring,"*",1). Once I changed it to Instr(1,Mystring,"*",1) and it worked. And to eliminate the "*" from the result field I modified the Left command as follows: Left(Mystring,(Instr(1,Mystring,"*",1)-1))

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

Similar Threads

  1. Replies: 5
    Last Post: 05-04-2019, 09:02 PM
  2. Replies: 22
    Last Post: 04-25-2012, 10:03 AM
  3. Using expression builder to find lowest date
    By MMcKenna in forum Queries
    Replies: 1
    Last Post: 03-20-2012, 02:28 PM
  4. Getting Expression-Relayed Data to Table
    By homerj56 in forum Programming
    Replies: 4
    Last Post: 09-10-2010, 08:56 AM
  5. Parse a File from a Directory and write data to table
    By galahad in forum Database Design
    Replies: 0
    Last Post: 04-23-2009, 08:38 AM

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