Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data type mismatch in criteria expression

Status
Not open for further replies.

DMG2000

Programmer
Aug 13, 2000
52
US
Everytime I try to call, or add to a primary key with a database, I get this error " Data type mismatch in criteria expression.", I know it has to be possible to get or update the primary key autonumber, but why isn't this working?
Code as follows:
sql= "insert into orderitems (orderid,productid, qty,priceperunit) values ('" & orderid & "','" & acart(i,0) & "','" & acart(i,1) & "','" & rsprice("saleprice") & "')"

Note: Bold is the primary key

Appreciate any thoughts!





 
It's NOT possible to update the Autonumber field !!!

Autonumber tales the next number you don't need to include it in your SQL INSERT INTO statement.

WP
 
Thanks WP:
I figured out what the error was. I was using adOpenDynamic when I should have been using adOpenKeyset...took long enough but after looking at the code for hours, it came to me. It wasn't that I wanted to add a new autonumber, but call the autonumber from the recordset based on the new entry, and then set it to a variable, but using adOpenDynamic, it resulted in the error. Go figure

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top