I'm using the following code in a combo box to search my customers:
My problem is that the search function is not able to tell the difference between customers with the same name but different address. This is because I'm calling "CustomerName" instead of CustomerID.
The form is based on a query "qryCustomerSearch" which returns CustomerID, CutomerName and Address. The combo box has the row source set to:
I have tried to call CustomerID instead of CustomerName in the code, but this only give me a error message. Any suggestions on how to fix this?
thanks!
Code:
Private Sub CtrlCustomer_AfterUpdate()
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[CustomerName] = '" & Replace(Me![CtrlSearch], "'", "''") & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub
My problem is that the search function is not able to tell the difference between customers with the same name but different address. This is because I'm calling "CustomerName" instead of CustomerID.
The form is based on a query "qryCustomerSearch" which returns CustomerID, CutomerName and Address. The combo box has the row source set to:
Code:
SELECT QryCustomerSearch.CustomerName, QryCustomerSearch.Address FROM QryCustomerSearch ORDER BY [CustomerName];
I have tried to call CustomerID instead of CustomerName in the code, but this only give me a error message. Any suggestions on how to fix this?
thanks!