Wednesday 15 June 2011

How to do an update query using a specific record from another table in Access? -


I am using Access 2010 and I want to know that a record from one table with information from another table How to update but also, I want to specify which record I want to use from that other table). I have two tables (products and sales) What do I need to do when I register a new sale on sale form (specify sold units), I want to discontinue the units sold from the available units of that product in the product table I am I have read that I need to use an update query, and do something like this:

  Field: Available units table: Update product: [Product]. [Available units] - [Sales] [Units sold] Field: Code table: Product to update: Benchmark: [Insert code]   

Two tables are related to the code field, going The primary key field from the Code products table (the products are registered only once) and the primary key field from the sales table is an auto-number field, called bactericulture. There may be many sales for one product.

I hope you can help me, I can not find anything. I am new to entry

You want to write a bit of VBA using a form and, You can make a submission button that moves according to your needs, something like this can appear:

  Private sub Submit_Button_Click () Dim set the record as string as MYR Set the record as strSQL, select the product from the myR2 'table that is available in the available products from strSQL = "Select * Available Available from YouTube Where Products = '' & Me.product_field & '' '' Set Each Table according to CurrentDb.OpenRecordset (strSQL, dbOpenDyanset) set as myR2 CurrentDb.OpenRecordset (" Sold_Units_Table ", dbOpenDynaset) 'This is the current amount that you will edit in the first table myR.Edit MYR set as MYR! [Product_Qty] = MYR [Product_Qty] -! Me.qty_sold myR.Update' for this transaction A new record will add meR2.addnew to myR2 in the second table [Product_Sold] = me.product_field myR2 [Product_Qty_Sold] = !. Qty_sold myR2.Update set MYR = nothing set myR2 = nothing End Sub   

Hope this would be a bit if you wanted to go to VBA route.

No comments:

Post a Comment