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