Hello ,
I have made some progress with what I would like to do but I am now questioning if it can be achieved at all
MS Access 2007.
Table Extraction Line
Field: Extraction ID: text data type (Primary key Compound)
Field: Atomic number:text data type (Primary key Compound)Field: Tonnage:Number data type
Field: worth:Currency data type
The 2 primary key fields are taken from the two tables that make up the 1:M relations for the extraction line table.
That is 1 resource is present in many extraction lines .
and 1 Mine extraction contains many extraction lines.
I have created a standard wizard form based on the fields of the extraction line table:
What I want to happen is:
As soon a user enters the tonnage value in the form.
In the afterupdate event for the tonnage field, but my preferred method would be in the control source for the worth field itself a Dlookup will look at the Resource table and find the Price field (currency data type).
It then multiplies the Resource table Price value with the tonnage amount field (e.g) $50 x 5 etc, the $250 value is then added to the worth field.
So far a simple Dlookup works I have entered this in the worth field control source for the extraction line form field :
=DLookUp("[Price]","[Resource]")
this displays 75 in the immediate test window and in the form is multiplied by whatever value I enter in the tonnage field.
The problem is I cannot get the dlookup to lookup up the value in the resource table that is also associated with the extraction ID so I get that specific resource value and not as I am getting the first price from the first record in the resource table. So far i have tried:
Attempt 1
=DLookUp("[Price]","[Resource]","'[Atomic Number] =[Extraction ID] And [Extraction ID] = [Atomic Number]'")*[tonnage]
Attempt 2
=DLookUp("[Price]","[Resource]","[Atomic Number] ="'[Extraction ID] And [Extraction ID] = [Atomic Number]'")*[tonnage]
error expected list separator or )
Attempt 3
=DLookUp("[Price]","[Resource]","[Atomic Number] =" & [ExtractionID])
=DLookUp("[Price]","[Resource]","[Atomic Number] =" & [Atomic Number] & " And ExtractionID=" & [ExtractionID])
Attempt 4
=DLookUp("[Price]", "[Resource]","[Atomic Number] = Form![EmployeeID]")
version 5
=DLookUp("[Price]", "[Resource]","[Atomic Number] = Form![Atomic Number]")
version 6
=DLookup("[Price]", "[Resource]","[Atomic Number]='" & [Atomic Number] & "'")
version 8
=DLookup("[Price]", "[Resource]","[Atomic Number]='" & [Atomic Number] & "'")
=DLookup("[Price]", "[Resource]", "[Atomic Number]='" & Forms![Extraction Line]![Atomic Number] & Forms![Extraction Line]![Extraction ID])
lol its not for the want of trying.
On some attempts I have omitted the * tonnage multiplication due to errors in the immediate window for the lookup part only.
Is it possible to do this with dlookup and i am making typo errors or is it not possible to Dlookup a value in a table then multiply it with a value in form field 1 to = a value in the form field 2
cheers