473,387 Members | 1,431 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Data Type Mismatch

I am currently trying to create my own Point Of Sale software for my
retail store. I wrote the program with the UPC field as Long integer.
When I started to add the products by UPC code, I got a data mismatch
error. I realized UPC codes are 12 digits, sometimes more and
sometimes less. This falls out of the Long integer field type. I then
changed my type on all UPC fields in all of the tables containing this
field to a text data type. This would allow me to enter the UPC codes
in; however, after doing this much of my code gave me data type
mismatch errors. I get this error when using the Find method to update
my inventory table to reflect the changes made to the inventory from
the sale transaction. I also get this error when I try using a SQL in
my code to select from the Inventory table the record that matches the
UPC of the sale. Does anybody have any suggestions? Here is some of
the code I'm having problems with:

Dim RstSaleDetails As DAO.Recordset
Dim RsttmpSaleDetails As DAO.Recordset
Dim RstDailySalesReport As DAO.Recordset
Dim strSQL As String

strSQL = "SELECT * FROM tblSalesDetails WHERE SalesID = " & txtSalesID
Set RstSaleDetails = CurrentDb.OpenRecordset(strSQL, dbOpenDynaset)
Set RsttmpSaleDetails = CurrentDb.OpenRecordset("tmptblSaleDetails")

RsttmpSaleDetails.MoveFirst

Do Until RsttmpSaleDetails.EOF
RstSaleDetails.FindFirst "UPC = " & RsttmpSaleDetails!UPC
If RstSaleDetails.NoMatch = True Then
RstSaleDetails.AddNew
RstSaleDetails!SalesID = txtSalesID
RstSaleDetails!UPC = RsttmpSaleDetails!UPC
RstSaleDetails!QtySold = RsttmpSaleDetails!QtySold
RstSaleDetails.Update
Else
RstSaleDetails.Edit
RstSaleDetails!QtySold = RstSaleDetails!QtySold +
RsttmpSaleDetails!QtySold
RstSaleDetails.Update
End If

RsttmpSaleDetails.MoveNext

Loop

Nov 13 '05 #1
3 5587

"Jake" <j.***********@mchsi.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
I am currently trying to create my own Point Of Sale software for my
retail store. I wrote the program with the UPC field as Long integer.
When I started to add the products by UPC code, I got a data mismatch
error. I realized UPC codes are 12 digits, sometimes more and
sometimes less. This falls out of the Long integer field type. I then
changed my type on all UPC fields in all of the tables containing this
field to a text data type. This would allow me to enter the UPC codes
in; however, after doing this much of my code gave me data type
mismatch errors. I get this error when using the Find method to update
my inventory table to reflect the changes made to the inventory from
the sale transaction. I also get this error when I try using a SQL in
my code to select from the Inventory table the record that matches the
UPC of the sale. Does anybody have any suggestions? Here is some of
the code I'm having problems with:

Dim RstSaleDetails As DAO.Recordset
Dim RsttmpSaleDetails As DAO.Recordset
Dim RstDailySalesReport As DAO.Recordset
Dim strSQL As String

strSQL = "SELECT * FROM tblSalesDetails WHERE SalesID = " & txtSalesID
Set RstSaleDetails = CurrentDb.OpenRecordset(strSQL, dbOpenDynaset)
Set RsttmpSaleDetails = CurrentDb.OpenRecordset("tmptblSaleDetails")

RsttmpSaleDetails.MoveFirst

Do Until RsttmpSaleDetails.EOF
RstSaleDetails.FindFirst "UPC = " & RsttmpSaleDetails!UPC
If RstSaleDetails.NoMatch = True Then
RstSaleDetails.AddNew
RstSaleDetails!SalesID = txtSalesID
RstSaleDetails!UPC = RsttmpSaleDetails!UPC
RstSaleDetails!QtySold = RsttmpSaleDetails!QtySold
RstSaleDetails.Update
Else
RstSaleDetails.Edit
RstSaleDetails!QtySold = RstSaleDetails!QtySold +
RsttmpSaleDetails!QtySold
RstSaleDetails.Update
End If

RsttmpSaleDetails.MoveNext

Loop


Since UPC is now a text field, when used in a WHERE clause, or Find, or
DLookup, etc you'll need to surround the argument with quotes.
For example, you could use"
RstSaleDetails.FindFirst "UPC = '" & RsttmpSaleDetails!UPC & "'"

HTH,
Randy
Nov 13 '05 #2
My thoughts on this are, if I am not going to sort or use the data in
calculations then I store it as text.

Nov 13 '05 #3
Change the following string as follows:

from: strSQL = "SELECT * FROM tblSalesDetails WHERE SalesID = " &
txtSalesID

to: strSQL = "SELECT * FROM tblSalesDetails WHERE SalesID = '" &
txtSalesID & "'"

Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: LJgrnl | last post by:
I've got a type mismatch error that's driving me nutty. Variable blnNoData has the initial value False. If a recordset comes back empty (both .EOF and ..BOF are true) then blnNoData is set to...
1
by: deko | last post by:
Okay, so I figured out how to pull Outlook Appointments into an Access Table (see below). But the data comes in the wrong Data Type - how do I convert it from Text to Long Integer? For...
2
by: Chicken Kebab Abdullah | last post by:
Does anyone know why I get the error 3464 Data type mismatch from the following code. I have a form with a combo(to choose a consumable) and 2 list boxes on it. list on left is all printers...
0
by: news.paradise.net.nz | last post by:
I have been developing access databases for over 5 years. I have a large database and I have struck this problem with it before but can find nothing in help or online. Access 2000 I have a query...
1
by: ArcadeJr | last post by:
Good morning all! I have been getting a Run-time Error message #3464 - Data Type mismatch in criteria expression. While trying to run a query. I have a database where the field Asset_Number...
1
by: amitbadgi | last post by:
I am getting the following error while converting an asp application to asp.net Exception Details: System.Runtime.InteropServices.COMException: Data type mismatch in criteria expression. ...
2
by: psychomad | last post by:
Please, can someone help me out to solve this error, i've been searching throughout my codes and yet i didnt succeed in finding the error!!!! The Error is: Server Error in '/' Application....
15
by: sara | last post by:
I have a Memo field in a table to hold notes from a conversation a social worker has had with a client (this is for a non-profit). If the user needs to update the memo field, I need to find the...
19
by: Lysander | last post by:
I have written a query that takes three integers representing day,month and year, forms a date from them and compares this date to the date the record was entered and returns any records where the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.