I'm not familiar with the DLookup function, but am trying to accomplish a task that I know should use this function and need some help with the code.
My scenario:
I have a "Add or Change Customer Orders" form that displays the OrderNumber, OrderDate, CustomerNumber, and CustomerName. This form has a subform that displays details about the order such as PartNumber, QuantityOrdered, SalePrice, and PartDescription.
The form gets its values from an Orders table that has OrderNumber, OrderDate, and CustomerNumber fields. The subform gets its values from an OrderLine table that has OrderNumber, PartNumber, NumberOrdered, and QuotedPrice fields.
Listing the part description in the subform is what I am having trouble with. I need the part description to be displayed to the right of each part number in the subform, but the part description is in a seperate table called Parts.
I know a DLookup is the superior way to do it, but I'm clueless how to implement it. A collegue mentioned I could "add a Text box and use the DLookup function" but I have no idea how to do that.
I tried looking online for some examples but just dont know how to adapt them for my situation. One example I found was this:
=DLookup ("[ProductName]","Products", "[ProductID] =" & Forms![Order Details]!ProductID)
But I dont know how to adapt that to make my form work rite. I've tried several variants with no success...
I've also attached an example screenshot of what I'm trying to achieve. The "Customer Name" field in the form, and the "Description" field in the subform are what I am trying to get working (didnt mention the Customer Name field in the form because I think I can get that working).
Any help would be greatly appreciated.
My scenario:
I have a "Add or Change Customer Orders" form that displays the OrderNumber, OrderDate, CustomerNumber, and CustomerName. This form has a subform that displays details about the order such as PartNumber, QuantityOrdered, SalePrice, and PartDescription.
The form gets its values from an Orders table that has OrderNumber, OrderDate, and CustomerNumber fields. The subform gets its values from an OrderLine table that has OrderNumber, PartNumber, NumberOrdered, and QuotedPrice fields.
Listing the part description in the subform is what I am having trouble with. I need the part description to be displayed to the right of each part number in the subform, but the part description is in a seperate table called Parts.
I know a DLookup is the superior way to do it, but I'm clueless how to implement it. A collegue mentioned I could "add a Text box and use the DLookup function" but I have no idea how to do that.
I tried looking online for some examples but just dont know how to adapt them for my situation. One example I found was this:
=DLookup ("[ProductName]","Products", "[ProductID] =" & Forms![Order Details]!ProductID)
But I dont know how to adapt that to make my form work rite. I've tried several variants with no success...
I've also attached an example screenshot of what I'm trying to achieve. The "Customer Name" field in the form, and the "Description" field in the subform are what I am trying to get working (didnt mention the Customer Name field in the form because I think I can get that working).
Any help would be greatly appreciated.