473,583 Members | 3,114 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 RsttmpSaleDetai ls As DAO.Recordset
Dim RstDailySalesRe port As DAO.Recordset
Dim strSQL As String

strSQL = "SELECT * FROM tblSalesDetails WHERE SalesID = " & txtSalesID
Set RstSaleDetails = CurrentDb.OpenR ecordset(strSQL , dbOpenDynaset)
Set RsttmpSaleDetai ls = CurrentDb.OpenR ecordset("tmptb lSaleDetails")

RsttmpSaleDetai ls.MoveFirst

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

RsttmpSaleDetai ls.MoveNext

Loop

Nov 13 '05 #1
3 5605

"Jake" <j.***********@ mchsi.com> wrote in message
news:11******** *************@z 14g2000cwz.goog legroups.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 RsttmpSaleDetai ls As DAO.Recordset
Dim RstDailySalesRe port As DAO.Recordset
Dim strSQL As String

strSQL = "SELECT * FROM tblSalesDetails WHERE SalesID = " & txtSalesID
Set RstSaleDetails = CurrentDb.OpenR ecordset(strSQL , dbOpenDynaset)
Set RsttmpSaleDetai ls = CurrentDb.OpenR ecordset("tmptb lSaleDetails")

RsttmpSaleDetai ls.MoveFirst

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

RsttmpSaleDetai ls.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 = '" & RsttmpSaleDetai ls!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
2487
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 True. I then have an if statement to determine what to write to the screen depending on blnNoData. As long as the if statement is true (doesn't have...
1
4948
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 example, If I have a custom Form in Outlook with and "Entity_ID" field, this number will come into the table as text - and every time I try to do...
2
10810
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 and list on right shows the ones currently compatible with the consumable chosen in the combo at the top.
0
2241
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 that will run fine without any criteria but as soon as I add any criteria it gives a "Data type mismatch" error. As soon as I remove any criteria...
1
6532
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 was once a type Number, but I had to change it to a type Text due to I needed to have two zeros at the beginning of the Asset Number (EX: 001234.) ...
1
3276
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. Source Error: Line 233: Line 234: rs =
2
8979
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. -------------------------------------------------------------------------------- Data type mismatch in criteria expression.
15
7342
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 original record (which I am doing fine - getting the correct key) and I need to update the "notes" with the new value from the form, which I store...
19
21545
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 date is more than 10 months out. The query runs fine, but I when I put the criteria of >10 I get 'Data Type mismatch' error. The code below is the...
0
7896
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7827
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8184
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8328
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7936
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8195
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6581
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5701
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5375
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...

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.