Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2015
    Posts
    1

    Unanswered: Left and Len aren't working for me...

    Hi All,

    So I'm trying to capture the left digits of numbers that are in a text field while leaving out the 2 most right digits. The code I'm using in my query is:

    left(len(my_field), -2)

    I thought this should work for a text field, but access is giving me a data type conversion error on all my fields. Once again I'm learning, but from the research I've done so far, it seems that a text field should be able to handle this code.

    What am I doing wrong?

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Say myfield contained '12345.6'
    Then your expression would be
    Left(len(myfield),-2)
    Or
    Left(7,-2)
    ...Is that what you intended?

    When the code halted, had you put your mouse cursor over the code you would see what it was doing.
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Apr 2004
    Location
    Derbyshire, UK
    Posts
    789
    Provided Answers: 1
    Hi

    Shouldn't it be

    MsgBox Left(my_field, Len(my_field) - 2)

    ??

    Note this will fail if Len(my_field) is less than 2 !!

    MTB

  4. #4
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Yes it should!
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  5. #5
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    ...of course it should be
    I'd rather be riding on the Tiger 800 or the Norton

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
  •