Hi can anybody help me with this problem?
I have a customer order form with a sales order line subform. The subform contains products ordered by customers, each (wooden) product can come in two different treatment types; golden brown or pressure treated of which are of two different prices. The prices are also determined by the customer type; pub, garden centre or public.
Currenlty on the treatment combo box, i have a dlookup in the code builder which looks up the price for the product dependant on whether GB (golden brown) or PT (pressure treated) is selected, this works fine for customer types pub (1) and garden centres (2) as the dlookup looks up the customertype and treatment type in a customertypepri ce table, and then displays the price in the unit price field on the subform, however for the public customer type, no prices are set in the customertypepri ce table as these need to be manually entered in.
I need to able to put this somewhere within the following code,something like 'if customer type = 3 (public) then set focus to the unit price field to allow me to enter a manual price. Does anybody have any ideas on how i can do this? The customer type field isnt within the subform but stored on the main form (frmcustomer3). Currently when i select customer type 3 on the main form and i select the treatment combo box an error occurs because the dlookup cant find customertype 3 in the customertypepri ce table.
Here is my current code:
Any suggestions would be great because ive been trying to do this for weeks!
I have a customer order form with a sales order line subform. The subform contains products ordered by customers, each (wooden) product can come in two different treatment types; golden brown or pressure treated of which are of two different prices. The prices are also determined by the customer type; pub, garden centre or public.
Currenlty on the treatment combo box, i have a dlookup in the code builder which looks up the price for the product dependant on whether GB (golden brown) or PT (pressure treated) is selected, this works fine for customer types pub (1) and garden centres (2) as the dlookup looks up the customertype and treatment type in a customertypepri ce table, and then displays the price in the unit price field on the subform, however for the public customer type, no prices are set in the customertypepri ce table as these need to be manually entered in.
I need to able to put this somewhere within the following code,something like 'if customer type = 3 (public) then set focus to the unit price field to allow me to enter a manual price. Does anybody have any ideas on how i can do this? The customer type field isnt within the subform but stored on the main form (frmcustomer3). Currently when i select customer type 3 on the main form and i select the treatment combo box an error occurs because the dlookup cant find customertype 3 in the customertypepri ce table.
Here is my current code:
Code:
Dim strFilter As String
strFilter = "ProductID = " & Me.ProductID & " And CustomerTypeID = " & Forms![frmCustomer3]![CustomerTypeID]
If Treatment.Value = "GB" Then
Me.SOUnitPrice.Value = DLookup("[GoldenBrownUnitPrice]", "tblCustomerTypePrice", strFilter)
ElseIf Treatment.Value = "PT" Then
Me.SOUnitPrice.Value = DLookup("[PressureTreatedUnitPrice]", "tblCustomerTypePrice", strFilter)
End If
Comment