Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2005
    Posts
    10

    Unanswered: How do you display characters in a field before space

    For example:

    In the address field 1000 My Way, I only want to display "1000".

    Cant use the Trim function because the street number could be anywhere from 2 to 5 characters depending on the address.

    I appreciate any help.

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    What you want to do is find where the first space is in the string.
    If memory serves correctly you want the InStr() function which goes a little something like this;
    Code:
    InStr(<StartPos>, <StringToSearch>, <StringToFind>)
    Which gives you...
    Code:
    Instr(1, AddressField, " ")
    This will return an integer value for the first occurrence of a space character (" ").
    You can then use the Left() function to trim the string up to this value
    Code:
    Left(<String>, <Length>)
    So if we combine the two;
    Code:
    Left(AddressField, Instr(1, AddressField, " ") - 1)
    I've added the minus 1 because you probably want to return "100" instead of "100 " (note the space).

    Hope this helps!
    George
    George
    Home | Blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •