I'm trying to make a form in Access where I will have a "search as you type" function to find a customer, and then I'll double click the correct match in a listbox in order to update the customer info textboxes. I succeeded the "search as you type" part, but not the listbox double click update form part.
I keep getting the following RunSQL error: "A RunSQL statement requires an argument consisting of an SQL statement"
The thing is that the SQL statement works just fine in a query.
Here's the code:
Private Sub lstClient_DblClick(Cancel As Integer)
Dim selectedItem, strSQL, strSQL1 As String
Dim i As Integer
i = lstClient.ListIndex
selectedItem = lstClient.ItemData(i)
txtCustName.Value = selectedItem
strSQL = "SELECT tblClient.[Addresse] FROM tblClient WHERE tblClient.[Nom] ='" & selectedItem & "';"
strSQL1 = "SELECT tblClient.[Addresse] FROM tblClient WHERE tblClient.[Nom] ='Bernache Funeral home';"
Text191.Value = strSQL1
Try something like
Dim db As Database Dim rs As DAO.Recordset Set db = CurrentDb Set rs = db.OpenRecordset(strSQL1) Text191.Value = rs.Fields("Addresse").Value Set rs = Nothing Set db = Nothing