I want to be able to populate a field in a form from another table, dependant on what is filled in on 2 previous form fields in the same form.
I have a company table with details on companies, I have waste-type table with details on several waste types, I have another table with default prices for companies and waste types. The company field and the waste-type field in the default-price table are both lookups from the company and waste-type tables.
I have a main data entry table, that requires the user to enter the company and waste type from lookup tables and I would like to pull in the default price to a field on the form so the user doesn't have to enter it all the time but can overwrite it if needed.
I am trying to use
Private Sub Price_GotFocus()
SetPrice = DLookup("Price", "Default_Prices", "[Company] = '" & Forms![Liquid_Docket_Data_Entry_with_Prices]![Company] & "'" _
And "[Waste_Type] = '" & Forms![Liquid_Docket_Data_Entry_with_Prices]![Waste_Type] & "'")
Liquid_Docket_Data_Entry_with_Prices]![Price] = SetPrice
End Sub
There are no errors when I go through the form but nothing populates the price field.
SetPrice is a global variable set as currency - done in module called Variable_Declaration