Consulting

Results 1 to 4 of 4

Thread: Do not understand method instr

  1. #1
    VBAX Regular
    Joined
    Jun 2007
    Posts
    22
    Location

    Do not understand method instr

    I am using this code in an login table for staff and have this validation code:
    InStr([Password],"password")=0

    But I do not fully understand what the method InStr is doing, like what is the return value of method Instr? Any help will help. Thank you

  2. #2
    VBAX Master CreganTur's Avatar
    Joined
    Jan 2008
    Location
    Greensboro, NC
    Posts
    1,676
    Location
    What exactly are you trying to accomplish? The code you provided and explination don't really make sense. Just write out, in detail, what you are hoping to accomplish and we'll be able to provide some help.
    -Randy Shea
    I'm a programmer, but I'm also pro-grammar!
    If your issue is resolved, please use Thread Tools to mark your thread as Solved!

    PODA (Professional Office Developers Association) | Certifiable | MOS: Access 2003


  3. #3
    VBAX Regular
    Joined
    Jun 2007
    Posts
    22
    Location
    Quote Originally Posted by CreganTur
    What exactly are you trying to accomplish? The code you provided and explination don't really make sense. Just write out, in detail, what you are hoping to accomplish and we'll be able to provide some help.
    It is doing a validation so the user cannot enter password as password

    here is the full validation code:
    Len([password])>=6 And Len([Password])<=15 And InStr([Password],"password")=0

    Help with InStr method would help

  4. #4
    VBAX Master CreganTur's Avatar
    Joined
    Jan 2008
    Location
    Greensboro, NC
    Posts
    1,676
    Location
    InStr returns the the position within a string where the string to look for can be found. It's for finding the starting position of the first occurance of a word or phrase within a string.

    You shouldn't be using InStr for your code. Try this instead:
    [VBA]Len([password]) > 6 And Len([Password]) <= 15 And [Password] <> "password"[/VBA]
    This code actually specifies the conditional that the value of the Password field cannot be a string with the value "password"
    -Randy Shea
    I'm a programmer, but I'm also pro-grammar!
    If your issue is resolved, please use Thread Tools to mark your thread as Solved!

    PODA (Professional Office Developers Association) | Certifiable | MOS: Access 2003


Posting Permissions

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