Insert query - Type mismatch

J

Jarryd

Hello,

Could someone please tell me what is wrong with my code:
----------------------------------------------------------------------------------
Private Sub btnApply_Click()
Dim Weight As Double
Dim Quantity As Long
Dim ordLink As Long
Dim qrySplit As String
Dim rstTRP As DAO.Recordset
Dim db As DAO.Database

ordLink = Form_Orders.txtOrd_Det_Lnk
Quantity = Form_Order_Details.txtQty - txtRolls
Weight = Form_Order_Details.txtWeight - txtkilos

qrySplit = "INSERT INTO Order_Details ( Orders_Link, Quantity, Weight )
VALUES (" + ordLink + ", " + Quantity + ", " + Weight + ");"

DoCmd.RunSQL ("qrySplit")

End Sub
------------------------------------------------------------------------------

I have checked the table Order_Details and the types are correct - Weight is
Double, Quanitity is Long Integer, Orders_Link is Long Integer.

TIA,

Jarryd
 
J

Jarryd

Apples and oranges. I was speaking the wrong language wasn't I? ' " & & "
'.

Jarryd
 
J

Jarryd

OK,

Wh do I get it now? This is excrutiating:
-----------------------------------------------------------------------
Private Sub btnApply_Click()
Dim Weight As Double
Dim Quantity As Long
Dim ordLink As Long
Dim Orig_Unique As Long
Dim Q_U As Long
Dim W_U As Double
Dim qrySplit As String
Dim qryUpd_Orig As String

ordLink = Form_Orders.txtOrd_Det_Lnk
Quantity = Form_Order_Details.txtQty - txtRolls
Weight = Form_Order_Details.txtWeight - txtkilos
Orig_Unique = Form_Order_Details.txtUnique
qrySplit = "INSERT INTO Order_Details ( Orders_Link, Quantity, Weight )
VALUES (' " & ordLink & " ', ' " & Quantity & " ', ' " & Weight & " ');"
qryUpd_Orig = "UPDATE Order_Details SET Quantity = (' " & Q_U & " '), Weight
= (' " & W_U & " ') WHERE Unique = (' " & Orig_Unique & " ');"
DoCmd.RunSQL qrySplit
DoCmd.RunSQL qryUpd_Orig

End Sub
----------------------------------------------------------------------
I have checked the types and they are correct. What am I doing wrong to get
Type Mismatch?

TIA,

Jarryd
 
G

Guest

Youe are putting single apostrophes around your variables. These are only for
strings. Ordlink, Quantity and Weight are Longs and Doubles so no apostrophes
required.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top