On a form (frmSUBINFO2), I have a combo box (called ‘L4’) and a bound text box (called ‘ShipContact’). The combo box is populated with a person’s initials after the user selects a name. The table underlying the combo box (tblDVCPERSONNEL) has 3 fields: Initials, FirstName, and LastName, with Initials as the bound column. After the user selects a name in the L4 combo box and populates it with initials, I want to automatically populate the ShipContact text box with the full name equivalent of those initials, but I can’t get it to work. Here’s the code I’ve placed in the After Update event of the L4 combo box:
Private Sub L4_AfterUpdate()
Dim strSQL As String
strSQL = “SELECT DISTINCTROW tblDVCPERSONNEL.FirstName & Chr(32) & tblDVCPERSONNEL.LastName ” _
& “FROM tblDVCPERSONNEL ” _
& “WHERE ((tblDVCPERSONNEL.Initials)=[Forms]![frmSUBINFO2]![L4])”
Me!ShipContact.ControlSource = strSQL
End Sub
This code generates a #Name! error message in the ShipContact field. What am I doing wrong? As always, many thanks for your help.