Copy field table in field of other table
Hello.
My base had 4 tables :
T_CUSTOMERS CUS_ID CUS_LAST_NAME CUS_FIRST_NAME
T_INVOICES INV_ID INV_DATE CUS_ID INV_VAT_RATE
T_INVOICES_SUB INV_ID PRO_ID INV_UPET INV_QTY
T_PRODUCTS PRO_ID PRO_LABEL PRO_UPET
I have a form called F_INVOICES. Within, the main form is frmInvoices and the subform is frmInvoicesSub. In this subform, I have a griddata called grdInvoicesSub (its table is T_INVOICES_SUB).
I have a listbox called lstProId for the column PRO_ID of the T_PRODUCTS table for select a product, with this in SQL mode :
SELECT "PRO_LABEL" || ' ' || "PRO_UPET" , "PRO_ID" FROM "T_PRODUCTS"
I'm seaching a macro for after selection of product and update of the lstProId listbox, I would like the PRO_UPET field of T_PRODUCTS to be copied in the INV_UPET field of the T_INVOICES_SUB field.
Important : PRO_UPET and INV_UPET must remain independent ; a subsequent change of the price in T_PRODUCTS table must not be reflected in the invoices already entered in T_INVOICES_SUB table. A JOIN type request is therefore not adapted.
Thanks.
Hello,
It is too difficult to give a simple answer with what you have presented. An SQL statement in a macro is easy enough but you need to get access to the data. This is via names used in the forms, sub forms, tables, and controls. There is also the method of processing. Based upon your statements this most likely needs to be done only on new records - freezing the price (this is not completely clear in the question). So then what happens when there is a problem with the price/record/quantity entered? Need another process?
There needs to be more answers to proceed and a sample (added to Question and not an Answer) to insure naming is correct and all works OK. There is a lot more to your question than simply updating a field.
Hello,
If you do not want to deal with learning LO API, try -> Access2Base. It is installed in LO. I do not use it (except for rare occasion of answering a simple question) since it is just another level of interpretation. It is also not as effective as the API.