I create a textbox "PhoneSearch", a listbox "PhoneList", and 3 labels "Name", "Phone" and "Address".
when enter a phone no. in PhoneSearch, then show the result in PhoneList.
if only one record is found, show the corresponding values into the 3 labels.
but in debug mode, one record is found, it call PhoneList_Click,
but Me.PhoneList.Column(0), Column(1), Column(2) all are null values.
what wrong in my coding?
Code:
Private Sub PhoneSearch_LostFocus()
Me.PhoneList.RowSource = "SELECT Name,Phone,Address FROM Contacts WHERE Phone LIKE '*" & Me.PhoneSearch & "*'"
If Nz(DCount("Phone", "Contacts", "Phone LIKE '*" & Me.PhoneSearch & "*'"), 0) = 1 Then
Me.PhoneList.Requery
PhoneList_Click
End If
End Sub
Private Sub PhoneList_Click()
Me.Name.Caption = Me.PhoneList.Column(0)
Me.Phone.Caption = Me.PhoneList.Column(1)
Me.Address.Caption = Me.PhoneList.Column(2)
End Sub