Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2004

    Unanswered: (Error 3071) With the following code.

    the code is asfollows

    IIf(Not InStr("IJQTUZ",Left$([registration],1))>0,IIf(Not InStr("IQZ",Mid$([registration],2,1))>0,IIf(Not InStr("IQ",Right$([registration],1))>0,T

    its to validate a british car reg plate.

  2. #2
    Join Date
    Apr 2004
    outside the rim
    There's a bunch wrong with the statement.

    The parenthesis don't match up - probably this that's causing the error. You have more "(" than you do ")"

    Also note that all your statements will ALWAYS be true:
    IIf(Not InStr("IQ",Right$([registration],1))>0,T
    This statement is mising the False condition and the closing ), but also the Right$ is taking 1 character from the field, your Instr function is looking for 2 characters. You will NEVER find 2 characters inside a 1 character string, so the return value will always be 0.

    The first statement is looking for "IJQTUZ" in 1 character:
    Left$([registration],1) and so forth.
    Also, the syntax of InStr is
    InStr([start, ]string1, string2[, compare])
    Some of your InStr functions have to many parameters.

    One last note: Left$, Mid$ and Right$ are all "String Functions" - if you get a null value in [Registration] you will get an error.

    I'd say "Have fun" as that's my trademark, but this doesn't look like much fun.

Posting Permissions

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