Unanswered: Multiplying two fields in a form from different tables
Im new to access so I would appreciate if somene can explain me in detail.
I have two tables 'LabIssue' and 'Store'.
I created a form for 'LabIssue' in which data will be entered. In the form I want to calculate the 'ChemicalAmount' by multiplying 'Store.Costperunit' with the 'QuantityIssued' which will be entered by the user. ChemicalAmount and QuantityIssued will be stored in 'LabIssue' table. I tried it through the expression builder but im getting #Name? error, did alot of things but couldnt figured out whats the problem.
i tried to run the second case but failed i think it is because 'Costperunit' is a column of store table and the form in which transaction will take place is based on 'LabIssue' table...so do i have to link store.costperunit with the LabIssue table.
please can you tell me in detail how to do this? I am stuck in this...i dont know how to use Dlookup. Help!
the DLookUp expression can be read as "retrieve the value of the column Costperunit from the table Store for one row matching the criteria".
If Costperunit is the name of a column of the table Store (i.e. if the expression Store.Costperunit is valid) and the whole statement "failed" (you do not specify what happened, which would be the most useful piece of information), it probably means that there is something wrong with the criteria.
No code can work as there is no code at all in your database.
Anyway, you do not need to use a DLookUp function to retrieve the value of Store.Costperunit as it is already present in the fourth column of the combobox named Combo297.
Open the module of the form LabIssue and paste this code into it then compile and save:
Option Compare Database
Private Sub Combo297_AfterUpdate()
Me!ChemicalAmount = Me.Combo297.Column(3) * Me.QuantityIssued.Value
Also, I don't understand what you try to achieve when placing:
in the AfterUpdate property of the textbox Text303.
Generally speaking, it would be advisable to rename the objects of the form and give meaningful names to them : It's hard to debug and maintain a database where the objects have names such as Combo297 (could be: Combo_Store) or Text303 (could be: Text_Qty_Issued).