Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Apr 2003
    Location
    Calgary, Alberta
    Posts
    327
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Comparing String (Access 2000)

    This is very odd. I have a barcode scanner which reads a barcode and stores in a text field. After that, I fire a query to check if the barcode exists into the data. For some reason, when I compare a string that starts with a 0, the system cannot find the match, eventhough the barcode is stored in the system.

    For example, if the value i am trying to match is 044444400018, it will not work, but if the value starts from a 1 - 9, it works fine

    Any ideas or things that I should lookout for when comparing strings.

    Basically, I have

    Set db = CurrentDb()
    Set rs2 = db.OpenRecordset("qry_GetInventoryProducts")

    rs2.FindFirst "Barcode LIKE " & CStr(Me!txt_ScannedBarcode)

    ' Get Product details to add or update
    If rs2.NoMatch Then

    MsgBox "This product does not exist inside the system." + rs2("Barcode")

    Me.txt_ScannedBarcode = ""
    Me.txt_ScannedBarcode.SetFocus

    Else

    .....

    End if


    Thanks

  2. #2
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Comparing String (Access 2000)

    Hi,
    I presume the barcode is stored as a string in your table, in which case I think you need to change your code to read:
    <pre>rs2.FindFirst "Barcode = '" & CStr(Me!txt_ScannedBarcode) & "'"
    </pre>

    Does that help?
    Regards,
    Rory

    Microsoft MVP - Excel

  3. #3
    3 Star Lounger
    Join Date
    Apr 2003
    Location
    Calgary, Alberta
    Posts
    327
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Comparing String (Access 2000)

    Yes, that does work perfectly!!!!!!!

    Thanks a ton

Posting Permissions

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