Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2005
    Location
    Nanded, India
    Posts
    397

    Unanswered: Data Type Mismatch In Criteria - Runtime error 3464

    Hi,

    First time I trying to use Metrologic barcode reader with MS Access. It is fully compitable with windows products. So no worry.

    In one of the subform field I placed On_Exit event and put below code so once barcode is read by reader, it would get field data into memory for further process. it reads barcode perfectly and automatically moves to next cell but then stops n gives this Data type mismatch error.


    Private Sub TxtBarcodeNumber_Exit(Cancel As Integer)
    Dim db As DAO.Database
    Dim rst As DAO.Recordset

    Set rst = CurrentDb.OpenRecordset("Select BarcodeNumber, ProductCode, ProductName " & _
    "From Product_master where BarcodeNumber=" & TxtBarcodeNumber)
    .....
    .....
    .......
    further code line.....


    But it gives me "Data type mismatch in Criteria error no. 3464"

    I used text data type for field BarcodeNumber. I may be wrong.

    Can somebody help me out...

    Thanks in advance.

    Ashfaque
    With kind regards,
    Ashfaque

  2. #2
    Join Date
    Nov 2003
    Posts
    1,487
    If the BarcodeNumber field is a TEXT datatype then you will need to enclose the TxtBarcodeNumber variable with apostrophes as shown below:

    Set rst = CurrentDb.OpenRecordset("Select BarcodeNumber, ProductCode, ProductName " & _
    "From Product_master where BarcodeNumber='" & TxtBarcodeNumber & "';")

    .
    Environment:
    Self Taught In ALL Environments.....And It Shows!


  3. #3
    Join Date
    Jan 2005
    Location
    Nanded, India
    Posts
    397

    Thumbs up

    Thanks CyberLynx

    It works perfectly now....thanks again.

    Do you advice me to use On_Exit event or some other event. Bcz I need once the reader reads the code, it should move to next rec.

    One more thing...I set text data type field for TxtBarcodeNumber field. Is it fine or need to select other data type. I believe the barcode result are always in integer. If I selects integer / double then the textbox can not accmodate the length of the barcode digits.

    Please advice.
    With kind regards,
    Ashfaque

  4. #4
    Join Date
    Nov 2003
    Posts
    1,487
    The Exit event is basically another Focus Type event. It fires before the LostFocus event and without looking at your particular application it would be hard for me to say....but my gut right now says no.

    The Text DataType can hold whatever size of number you want.....you just have to remember that it is considered a String and not a Number. To use the BarCode value within that table field as a number you will need to carry out conversions which in my opinion always leads to problems down the road.

    If the BarCode values you are getting are of the integer type, then your table field datatype should be of that same type. You will have far less problems down the road.

    Is it fine to do that change now? It depends on a number of items. Are there Relationships involved? Are there queries that need to be changed because of the Type change? ... etc.

    Make a Backup copy of your Database and put it in a safe place. Then try it. Make the necessary changes as problems are encounter if at all (you most likely will). Test everything including your reports etc. If you are happy with the results, then you've done it

    If you do change the DataType for the table field holding the BarCode value then you will definately need to modify the query I provided in the above post....to the query you originally posted yourself.

    .
    Environment:
    Self Taught In ALL Environments.....And It Shows!


  5. #5
    Join Date
    Jan 2005
    Location
    Nanded, India
    Posts
    397
    IC

    Thanks again CyberLynx
    With kind regards,
    Ashfaque

Posting Permissions

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