title: MS Access: Action "onchange" event after a delay?
body: <p>Good morning!</p>
  
  <p>I have a "fancy" search function in Microsoft Access where the list of possible options shrinks as you type in the search field. Unfortunately the computer and server can't keep up with these rapid requeries of the data.</p>
  
  <p>Currently the command to requery with the field in the 'onchange' function of the search box. I'd like to add a delay so it only runs the requery when the search box has not changed for a second. Thus if someone types in a 8 letter word, it isn't running 8 requeries.</p>
  
  <p>The current idea I have for it, which I know there must be something better, is..</p>
  
  <p>"On change, set search box value to X and wait 1 second. After 1 second, if X = search box value, run the requery. An issue is that it would be rapidly rewriting the X value and have a 'wait' command floating for each letter.</p>
  
  <p>Hopefully there's a way to write an event trigger of "When field X has changed, but not changed for the past second."</p>
  
  <p>Thank you!</p>
  
  <p>As requested, here is my current code</p>
  
  <pre><code>'Create a string (text) variable
      Dim vSearchString As String
  'Populate the string variable with the text entered in the Text Box SearchFor
      vSearchString = SearchFor.Text
  'Pass the value contained in the string variable to the hidden text box SrchText,
  'that is used as the sear4ch criteria for the Query QRY_SearchAll
      SrchText = vSearchString
  'Requery the List Box to show the latest results for the text entered in Text Box SearchFor
      Me.SearchResults.Requery
      Me.SearchResults2.Requery
  'Tests for a trailing space and exits the sub routine at this point
  'so as to preserve the trailing space, which would be lost if focus was shifted from Text Box SearchFor
      If Len(Me.SrchText) &lt;&gt; 0 And InStr(Len(SrchText), SrchText, " ", vbTextCompare) Then
          'Set the focus on the first item in the list box
              Me.SearchResults = Me.SearchResults.ItemData(1)
              Me.SearchResults.SetFocus
          'Requery the form to refresh the content of any unbound text box that might be feeding off the record source of  the List Box
              DoCmd.Requery
          'Returns the cursor to the the end of the text in Text Box SearchFor,
          'and restores trailing space lost when focus is shifted to the list box
              Me.SearchFor = vSearchString
              Me.SearchFor.SetFocus
              Me.SearchFor.SelStart = Me.SearchFor.SelLength
              Exit Sub
      End If
  'Set the focus on the first item in the list box
  '    Me.SearchResults = Me.SearchResults.ItemData(1)
      Me.SearchResults.SetFocus    
  'Requery the form to refresh the content of any unbound text box that might be feeding off the record source of  the List Box
      DoCmd.Requery
  'Returns the cursor to the the end of the text in Text Box SearchFor
      Me.SearchFor.SetFocus
      If Not IsNull(Len(Me.SearchFor)) Then
          Me.SearchFor.SelStart = Len(Me.SearchFor)
      End If
  </code></pre>
  
  <p>Obviously this is not MY code, it's from somewhere on the interweb. It works fantastic for databases stored locally, but everything is moving to our Sharepoint server which is running on a 386 in a moldy basement powered by a narcoleptic gerbil.</p>