Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.
One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.
Option Compare Database Const constErrNoError = 0 Const constQuote = """" Public Function SearchRecordset(ctlText As Control, _ ctlList As Control, strBoundField As String) As Variant ' Search through a bound listbox, given text to ' find from a text box. ' Move the list box to the appropriate row. ' The listbox can have either a table or a dynaset ' (a query or an SQL statement) as its row source. ' In: ' ctlText: a reference to the text box you're typing into ' ctlList: a reference to the list box you're looking up in ' strBoundField: the name of the field in the underlying ' table in which you're looking for values. ' Out: ' Return value: either 0 (no error) or an error variant ' containing the error number. Dim rst As DAO.Recordset Dim varRetval As Variant Dim db As DAO.Database On Error GoTo HandleErr Set db = CurrentDb() Set rst = db.OpenRecordset(ctlList.RowSource, dbOpenDynaset) ' Use the .Text property, because you've not yet left the ' control. Its value (or its .Value property) isn't ' set until you leave the control. rst.FindFirst "[" & strBoundField & "] >= " & _ constQuote & ctlText.Text & constQuote ' Find a match? Set the ListBox to ' the correctly value. If Not rst.NoMatch Then ctlList = rst(strBoundField) End If varRetval = constErrNoError ExitHere: SearchRecordset = varRetval On Error Resume Next rst.Close Set rst = Nothing Exit Function HandleErr: varRetval = CVErr(Err) Resume ExitHere End Function Private Sub List11_AfterUpdate() UpdateSearch Me.Text9, Me.List11 End Sub Private Sub Text9_Change() SearchRecordset Me.Text9, _ Me.List11, "LastName" End Sub Private Sub Text9_Exit(Cancel As Integer) UpdateSearch Me.Text9, Me.List11 End Sub
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
|Create a varying recordset||5||53|
|Converting Access 2016 from 32-bit to 64-bit||8||57|
|Add a record to a table when enter value in a combobox||7||32|
|Access 2003, find all instances of database ODBC||3||48|
Join the community of 500,000 technology professionals and ask your questions.