expressions

astarbyfar

Registered User.
Local time
Today, 19:39
Joined
Apr 27, 2003
Messages
93
Im creating a stock control system and I need an expression so that when i click on a button the quantity is deducted by 1. The table is Stock and the attribute is called Quantity i've created a query but i dont know whether this is right. Please help
 
Use an update query to update the value to [CurrentStock]-1

However, as you probably can calculate how much stock is going in and out you do not really need this field because it is a function of other information you already hold and can be calculated in a grouping query.(TotalStockHeld - StockOut).

This is better because you don't have to handle scenarios of orders being cancelled, stock returns etc..these should all be accounted for elsewhere and are then be automatically incorporated into any calculations of stock level.
 
Im not to sure what you mean, ive created a query which asks the user which has

Item number
Description These are all shown
Price

Then there is

Quantity which is not shown

I have then created a form with the data source being the above query which is called Stock. I have then created a button which when pressed should minus quantity by 1 the code i have put in is

[Stock]![Quantity] = ([Stock]![Quantity] - 1)

And this is done in the expression. However im getting this error message saying

The expression OnClick you entered as the event property setting produced the following error: The object doesnt contain the automation object "Query2."

The expression may not result in the name of a macro , the name of a user defined function, or [Event procedure]
There may have been an error evaluating the function, event or macro

Should i be doing this in a macro?
 
Apoligies where it has query1 in the erro message that should be Stock
 
Against my better judgement you should place this code in the form module in the OnClick event of the button

Me.Quantity = Me.Quantity- 1
 

Users who are viewing this thread

Back
Top Bottom