Private Sub search_company_Change() Dim SQL As String Dim recClone As Object Me!lbCompanies.RowSource = "SELECT * FROM tbl_Contacts Where [company_name] Like '" & Me.search_company.Text & "*' ORDER BY [company_name] ASC;" SQL = " SELECT * FROM tbl_Contacts Where [company_name] Like '" & Me.search_company.Text & "*' ORDER BY [company_name] ASC;" Form.RecordSource = SQL Set recClone = Me.RecordsetClone ' Check to see if there are no records If recClone.RecordCount = 0 Then cmdNext.enabled = False cmdPrevious.enabled = False cmdFirst.enabled = False cmdLast.enabled = False Else Me![RecordCount] = "Contact " & (recClone.AbsolutePosition + 1) & " of " & _ DCount("company_id", "tbl_contacts", SQL) recClone.Close DoCmd.RunCommand acCmdRefreshPage End If End Sub
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.