I am creating an orders form inwhich the user will select a company from a combo box that is linked to the Customer Table. I have attempted to display the "Address" of that company in a Text Box below the company name on the form using DLookup to no avail. My current code gives me an address however it is always the address of the first company in the table
My current code consists of...
Private Sub CustomerID_AfterUpdate()
Me!Address = DLookup("[ShipAddress]", "Customers", "[CustomerID]= CustomerID")
End Sub
Where...
Address = The name of the field in the form where I want the address displayed
ShipAddress = The name of the field in the Customers table
Customers = The name of the table
CustomerID = The Company ID (Displayed in my Form as the Company Name)
Customer ID = The Value stored in my Form
I have successfully used the DLookup function elsewhere in a subform but I just can not seem to get this one to work. Any help in solving or troubleshooting would be appreciated.
My current code consists of...
Private Sub CustomerID_AfterUpdate()
Me!Address = DLookup("[ShipAddress]", "Customers", "[CustomerID]= CustomerID")
End Sub
Where...
Address = The name of the field in the form where I want the address displayed
ShipAddress = The name of the field in the Customers table
Customers = The name of the table
CustomerID = The Company ID (Displayed in my Form as the Company Name)
Customer ID = The Value stored in my Form
I have successfully used the DLookup function elsewhere in a subform but I just can not seem to get this one to work. Any help in solving or troubleshooting would be appreciated.