How to populate fields in tab control when entering firstname in text search box; VBA7?

13 Views Asked by At

So,I have btnSearch when click it will populate myTabControl23. I been trying to search by first name and to populate the tab control but it cant.

Private Sub btnSearch_Click()
    SearchAndPopulate
End Sub

Private Sub SearchAndPopulate()
        Dim searchCriteria As String
        searchCriteria = Me.txtSearch.Value  
    
        ' Your query to retrieve data based on search criteria
        Dim strSQL As String
        strSQL = "SELECT * FROM tblPersonal " & _
                 "WHERE PersonnelID = " & searchCriteria & ";"
    
        ' Execute the query
        Me.RecordSource = strSQL
    
        ' Refresh the form to display the updated records
        Me.Refresh
        
        Debug.Print "SQL Query: " & strSQL
    End Sub

I have tried some tutorial to add FirstName as search but I got errors. I then revert back to search by ID.

Note the form row source control is wired to tblPersonal.

Please can someone help me on how to search by firstname and on selection it populates the tab control.

Below is my tab control image;

Tab Control Image

0

There are 0 best solutions below