Unanswered: Data Type Mismatch In Criteria - Runtime error 3464
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.
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.
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.
Self Taught In ALL Environments.....And It Shows!