M
MAC
Dear list,
I have a database regarding meal plans called "MealPlan" with the fields
ID, MealPlan, Price and PlanCost. I have a corresponding form, also called
"MealPlan", in which the user will select the meal plan from a dropdown. I
have a procedure that will insert the price of the corresponding meal plan
in the field PlanCost AFTER selection is made from the MealPlan dropdown.
From subform "Orders" in the Northwind database, I adapted the following
procedure:
Dim strFilter As String
'Evaluate filter before it's passed to Dlook up function
strFilter = "Price = " & Me!Price
'Look up price & assign it to Meal Price control
Me!PlanCost = DLookup("Price", "MealPlan", strFilter)
Exit_Choice_AfterUpdate:
Exit Sub
Err_Choice_AfterUpdate:
MsgBox Err.Description
Resume Exit_Choice_AfterUpdate
1) It works fine as a standalone form (that is, once I select the mealplan,
its corresponding price is inserted in the PlanCost field), but when I
insert this form as a subform, linking by the field "ID" (for each unique
user), it can't evaluate the function, saying that there's a missing
operator in Price. What am I doing wrong?
2) The MealPlan lookup table should not be changed but just populate the
field PlanCost, but because it's linked to the ID field, it keeps adding ids
and choices to the lookup table.
Thank you in advance for any assitance!!!
I have a database regarding meal plans called "MealPlan" with the fields
ID, MealPlan, Price and PlanCost. I have a corresponding form, also called
"MealPlan", in which the user will select the meal plan from a dropdown. I
have a procedure that will insert the price of the corresponding meal plan
in the field PlanCost AFTER selection is made from the MealPlan dropdown.
From subform "Orders" in the Northwind database, I adapted the following
procedure:
Dim strFilter As String
'Evaluate filter before it's passed to Dlook up function
strFilter = "Price = " & Me!Price
'Look up price & assign it to Meal Price control
Me!PlanCost = DLookup("Price", "MealPlan", strFilter)
Exit_Choice_AfterUpdate:
Exit Sub
Err_Choice_AfterUpdate:
MsgBox Err.Description
Resume Exit_Choice_AfterUpdate
1) It works fine as a standalone form (that is, once I select the mealplan,
its corresponding price is inserted in the PlanCost field), but when I
insert this form as a subform, linking by the field "ID" (for each unique
user), it can't evaluate the function, saying that there's a missing
operator in Price. What am I doing wrong?
2) The MealPlan lookup table should not be changed but just populate the
field PlanCost, but because it's linked to the ID field, it keeps adding ids
and choices to the lookup table.
Thank you in advance for any assitance!!!