I have a form where I select or type an account number from a dropdown combo list field and it navigates to that record. I'm trying to add another field (the address field) to do the same. I've come up short on all other means of trying to accomplish this, so I came up with trying to lookup the account number based on the address entered (dlookup) and have the DB enter it in the account number field, hence will navigate to the correct record.
Private Sub Address_AfterUpdate()
Me.CustomerID = DLookup("[ID]", "Customers", "address = " & Address)
End Sub
After the field is updated, it gives me rather the error "Runtime Error 3464 Data type mismatch in criteria expression" or if I change a few things "runtime Error 3075 Syntax Error (missing operator) in query expression '[address] = 123 Main St'
Correct me if I am worng, but this should translate to: enter the value of the [ID] field in the "customers" table into the CustomerID field of the form where the "Address" field of the customers table is the same as the Address field i just entered in the form.
I don't know what I'm doing wrong here. The data types in the table and form are both set to text.
Private Sub Address_AfterUpdate()
Me.CustomerID = DLookup("[ID]", "Customers", "address = " & Address)
End Sub
After the field is updated, it gives me rather the error "Runtime Error 3464 Data type mismatch in criteria expression" or if I change a few things "runtime Error 3075 Syntax Error (missing operator) in query expression '[address] = 123 Main St'
Correct me if I am worng, but this should translate to: enter the value of the [ID] field in the "customers" table into the CustomerID field of the form where the "Address" field of the customers table is the same as the Address field i just entered in the form.
I don't know what I'm doing wrong here. The data types in the table and form are both set to text.
Last edited: