PDA

View Full Version : SOL/Access Problem



SLH
03-16-2007, 08:53 AM
Hi, Making a stock management control in Access with VBA on top.

Currently trying to use a docmd.runsql with this:


UPDATE Components _
SET Components.NumberInStock = [NumberInStock]-"1" _
WHERE (((Components.ComponentID)=[forms]![Bookings]![ComBook]![comComponentID]));

So this decreases the stock by one, when the event is called.

Problem is if i put it in VBA even before executing it, it has a paddy over the 1.

The SQL originally came from a QBE in Access. Anyone any idea of how to fix the bracketing?

Edited 19-Mar-07 by geekgirlau. Reason: insert line breaks

OBP
03-16-2007, 11:14 AM
"1" is text for the value 1.
I just ceated an "Update" Query to do what you want and it produced this SQL


UPDATE [Transaction] SET [Transaction].DRAmount = [DRAmount]+1;

Sorry mine added one but the principle is correct.
But what happens if you have a Zero value?

This one reduces by 1.


UPDATE [Transaction] SET [Transaction].DRAmount = [DRAmount]-1;