Update statements ceases to work

  • Thread starter Thread starter Rolf Rosenquist
  • Start date Start date
R

Rolf Rosenquist

These lines works when the "newstock" value is an integer.

newstock = instock - orderamount
cmdText = "UPDATE tblProduct SET [instock] = " & newstock & "WHERE
[productID] = " & [order.productID] & ";"
DoCmd.RunSQL cmdText

The fields instock and orderamount in the tables Product and Order are set
to long integer.

Then I came to the insight that I needed to let the user set the orderamount
to a decimal number, so I changed the those fields in both tables from
integer to double, but then I get an syntax error with the UPDATE.

It is possible to set those fields to a decimal value direct in both tables.
It puzzles me that when so done, I can run the command above, when the
result generates an integer to be updated. But not when it will be a decimal
value.

Is there more than the table fields that must be changed to take a decimal
value?
/ Rolf
 
I have a space after the "=" and the line works with integers.
It is the decimal values that are the problem.
/ Rolf



Robbie said:
Try putting a space before the 'W' in Where

Rolf Rosenquist said:
These lines works when the "newstock" value is an integer.

newstock = instock - orderamount
cmdText = "UPDATE tblProduct SET [instock] = " & newstock & "WHERE
[productID] = " & [order.productID] & ";"
DoCmd.RunSQL cmdText

The fields instock and orderamount in the tables Product and Order are set
to long integer.

Then I came to the insight that I needed to let the user set the orderamount
to a decimal number, so I changed the those fields in both tables from
integer to double, but then I get an syntax error with the UPDATE.

It is possible to set those fields to a decimal value direct in both tables.
It puzzles me that when so done, I can run the command above, when the
result generates an integer to be updated. But not when it will be a decimal
value.

Is there more than the table fields that must be changed to take a decimal
value?
/ Rolf
 
No problem anymore. I found out why it said syntax error with decimal
numbers but not with integers.
/ Rolf
 
Back
Top