hi Emily,
Can someone help me to figure what is wrong with my syntax?
Thanks...
How to open with this ( " ) and sometimes with this ( ' )?
You always use " or ' to mark the start and end of a string. In VB(A)
only " is an allowed string delimiter. In Jet SQL you may use " or '.
SQLString = "insert into WIPRawDetails (JobNumber, PartNumber, W_KittedQty) "
& _
"select '" & Me.txtJobNumber & "', " & _
'"& Me.txtPartNumber & "', " &_
'" & Me.I_Qty & "' , " &_ from WIPRawDetails "
First of all write it down in plain SQL using real data:
INSERT INTO WIPRawDetails (JobNumber, PartNumber, W_KittedQty)
SELECT 'abc123', 'abc123', 1
FROM WIPRawDetails
or
INSERT INTO WIPRawDetails (JobNumber, PartNumber, W_KittedQty)
SELECT "abc123", "abc123", 1
FROM WIPRawDetails
Question: Of what kind of data type are these fields? Text or number?
In the above example i have made the assumption that JobNumber and
PartNumber is alphanumeric and W_KittedQty is numeric.
When it comes down to assemble this SQL in VB(A) you need to escape " if
they are constants in your SQL. Escaping means that you need to double
them. So the two examples will look like:
SQLString = "INSERT INTO WIPRawDetails " & _
"(JobNumber, PartNumber, W_KittedQty) " &_
"SELECT '" & txtJobNumber.Value & "', '" & _
txtPartNumber.Value & "', " & Me.I_Qty & " " & _
"FROM WIPRawDetails"
and
SQLString = "INSERT INTO WIPRawDetails " & _
"(JobNumber, PartNumber, W_KittedQty) " & _
"SELECT """ & txtJobNumber.Value & """, """ & _
txtPartNumber.Value & """, " & Me.I_Qty & " " & _
"FROM WIPRawDetails"
mfG
--> stefan <--