copy data from 1 table to a second table

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

If i have a table called "master" and it has the following fields,
"partnumber" "description" "price" and "qty" and i get the iformation using a
subform, and it writes the information to a tabel named "mastersubform", how
if i alter the "qty" field in the subform do i write the new "qty" to the
original table "master"

i know i shouldn't write to tables, but as the price alters if i don't write
it it will change my data if the price changes and in this instance the price
is dynamic and can alter avery day or so, therefore i need to write the data.

Plase help what code i could write in the "after exit".
 
Hi Kevin,

I am a bit confused about what you are specifically asking, as you started
out talking about qty then ended up talking about the price changing... but
anyway...

To update a table, you could use either of the following methods:

In the after update event of the qty control, run an SQL update statement:

docmd.runsql "update TABLENAME set FIELDNAME = NEWVALUE where ID = " &
me.IDFIELD

Or, if the field lives on the master form, you could simply update the value
in the field, eg:
me.parent.FIELDNAME = NEWVALUE

Hope this helps.

Damian.
 
I tried the code and i keep geting errors, the code is

DoCmd.RunMacro "update stock set quantityinstock = tempqty where stocknumber
=" & Me.PartNo
Me.tempqty = 0

Where he master file info is "Stock" is the name of the table, "stocknumner"
is the ID and "quantityinstock" is the field name, in the subform the ID is
"Partno" and the filed name is "tempqty"

I think i am getting closer, i just cant get there. I fully understand that
i have probably set it up wrong, but i need to work around what i have.
 
Back
Top