I have a form where the user searches an access DB, the user will use this all day. Doing new searches all the time.


VB Code:
  1. Private Sub cmdStart_Click()
  2.     'Free Memory
  3.     Set txtContactID.DataSource = Nothing
  4.     Set txtFirstName.DataSource = Nothing
  5.     Set txtLastName.DataSource = Nothing
  6.     Set txtHomePhone.DataSource = Nothing
  7.     Set txtWorkPhone.DataSource = Nothing
  8.    
  9.     If rsContacts.State = 1 Then
  10.         rsContacts.Move 0
  11.         rsContacts.Close
  12.     End If
  13.     Set rsContacts = Nothing
  14.    
  15.     'Open new data
  16.     Set rsContacts = New ADODB.Recordset
  17.     rsContacts.Open "SELECT * FROM Contacts WHERE LastName = '" & txtSearch.Text & "'", dbContacts, adOpenStatic, adLockOptimistic, adCmdText
  18.  
  19.     Set txtContactID.DataSource = rsContacts
  20.     Set txtFirstName.DataSource = rsContacts
  21.     Set txtLastName.DataSource = rsContacts
  22.     Set txtHomePhone.DataSource = rsContacts
  23.     Set txtWorkPhone.DataSource = rsContacts
  24. End Sub

It works fine... Almost..

After using it for several hours it becomes really slow. If you restart the app, it speeds back up again.

I modified it to run 100 searches in a row and time each search. Indeed it does get slower and slower and slower.

Above is the ONLY code executed between searches. I cannot figure out how to fix this. I know I could just set the text of the textboxes instead of binding them to the recordset, but I'd really prefer not to do that..

Any help would be awesome!