Help with access.

Caporegime
Joined
12 Mar 2004
Posts
29,962
Location
England
How do I get a database to automatically update another table, say reduce the number of an items in stock by one after it has been added to a purchase?
 
Ok,

just so we can get the common terms straight so we are both talking about the same thing, do you mean;

How do you get a form (ie. purchase_form) to update a table (ie. stock_table) in the database (ie. Inventory DB) whilst also inserting a record into another table (ie. sales_table) when the forms ok button is pressed ?.

or

How do you get a form (ie. purchase_form) to update a table (ie. stock_table) in a database (ie. Inventory DB) whilst also inserting a record into another table (ie. sales_table) in another database (ie. sales_db) when the forms ok button is pressed ?.

For the first one then;

'cmdo.runsql $sql'

with $sql having the value of something like

$sql = 'update stock_table set quantity = quantity -1 where stock_code = " & me.stock_item_cbx.Column(0)

this is assuming that the update is being kicked off from the purchase form so the me.[control name] should work and the stock_item_cbx is a combobox which has two columns, 0 containing the stock_code and hidden and 1 containing the stock item name which the user / sales person can select.

For the second one I would start looking at ADO or DAO to open two seperate databases at the same time.

RB
 
Back
Top Bottom