I have a basic invoicing setup, with a Form (Invoices) and subform (InvoiceDetails).
When in the subform, i have a combo box to choose a Product Code (saved in table as PCode).
I want now to auto fill in the NettPrice and (Product Description) PDesc fields in the subform row - by looking these up in the Products Table and entering the data into the relevant fields on the Subform. This lookup will be based on PCode.
I tried all sorts of methods and the one i favour, if i could get it to work, is setting up a Function then calling this function from the Default Value property of each field involved.
So, for the Product Description field (PDesc), i created a Function as follows:
Function GetDesc () As String
GetDesc = DLookup ("[PDesc]", "[Products]", "[PCode] = " & Forms!InvoiceDetails!PCode)
End Function
Then i try to call by entering =GetDesc () into the Default Value property for the PDesc field.
I seem to have a syntax problem with my function code......any ideas?
Please note, I am a complete novice, so assume i don't know much. Also I know some of my values like NettPrice need not be fields on my Invoice Details table, but the prices change and I also need to be able to overwrite prices etc when typing invoice (products table price is only a guide price).
Thanks in advance
When in the subform, i have a combo box to choose a Product Code (saved in table as PCode).
I want now to auto fill in the NettPrice and (Product Description) PDesc fields in the subform row - by looking these up in the Products Table and entering the data into the relevant fields on the Subform. This lookup will be based on PCode.
I tried all sorts of methods and the one i favour, if i could get it to work, is setting up a Function then calling this function from the Default Value property of each field involved.
So, for the Product Description field (PDesc), i created a Function as follows:
Function GetDesc () As String
GetDesc = DLookup ("[PDesc]", "[Products]", "[PCode] = " & Forms!InvoiceDetails!PCode)
End Function
Then i try to call by entering =GetDesc () into the Default Value property for the PDesc field.
I seem to have a syntax problem with my function code......any ideas?
Please note, I am a complete novice, so assume i don't know much. Also I know some of my values like NettPrice need not be fields on my Invoice Details table, but the prices change and I also need to be able to overwrite prices etc when typing invoice (products table price is only a guide price).
Thanks in advance