I AM STUMPED.
I have a field (Prospect Name) in a form (Listing Leads) that uses a combo box to select a name from "Contacts Query". The Contacts Query has 6 fields: FirstName, LastName, BusinessPhone, MobilePhone, EmailAddress, and Expr. Expr is "Expr: [FirstName] & " " & [LastName]". And it probably has about 1,100 records.
So the Prospect Name field/combo box works GREAT, but I'd also like it to auto populate the rest of the fields in the Listing Leads form. Under "AfterUpdate", the code reads as follows:
Email = DLookup("EmailAddress", "Contacts Query", "Expr")
This is obviously only 1 of 6, but you get the point. And this brings up my 1st contact's email address, which is great. But as you can probably tell by the code, it brings up his address regardless of the name I type in the Prospect Name field. (I only point this out to let you know that it works up to this point.) So when I include the following code:
Email = DLookup("EmailAddress", "Contacts Query", "Expr=" & Prospect Name)
a dialog box opens that reads: "Compile error: Expected: list separator or)".
Here's what the entire code looks like:
Option Compare Database
Private Sub Form_Open(Cancel As Integer)
End Sub
Private Sub Prospect_Name_AfterUpdate()
Email = DLookup("EmailAddress", "Contacts Query", "Expr=" & Prospect Name)
End Sub
And here's the error message that comes up after I type someone's name in the Prospect Name field: "Compile Error: Syntax Error." And in the VBA, it highlights the following: Private Sub Prospect_Name_AfterUpdate()
Any ideas?