Results 1 to 5 of 5
  1. #1
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    INSTR not finding chr(194) (Access 97)

    Can someone tell me how to use Instr to find chr(194) in a string?

    I use a vbBinaryCompare in the Instr instruction. Is this the problem?

    Or can I use a character to search that has a decimal value greater then 128?

    I am not at the client site so i cant test this.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: INSTR not finding chr(194) (Access 97)

    Are you doing this in VBA, or in an expression in a query or in the control source of a control on a form or report?

    In VBA, either InStr(1, StringVariableOrExpression, Chr(194)) or InStr(1, StringVariableOrExpression, Chr(194), vbBinaryCompare) should work.
    In a query or on a form or report, you can't use vbBinaryCompare, so you should either omit it or use 0 instead.

  3. #3
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: INSTR not finding chr(194) (Access 97)

    Thanks Hans, that part answers the question. I am doing it in VBA and it seems like vbTextCompare is not the way to go but I should be using vbBinaryCompare instead.

    Is that right

    Would you tend to use vbBinaryCompare all the time??

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: INSTR not finding chr(194) (Access 97)

    I normally omit the Compare argument from InStr, so that it uses the option declared at the top of the module:

    Option Compare Database

    This means that string comparisons will use the locale set for the database. I'd use vbBinaryCompare if I'd want to distinguish between lower case and upper case (they are normally seen as the same in string comparisons, i.e. "Pat" is seen as equal to "pat").

  5. #5
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: INSTR not finding chr(194) (Access 97)

    Good to know, thanks Hans

Posting Permissions

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