I've been revising this app for some time now. I've gotten rid of a ton of objects that have been accruing for the last dozen year and tried to speed up some time consuming data entry procedures. One time consuming task involved updating an existing applicant record. This Applicant table is fairly large (160,000 records) and heavily indexed. Every time I think I've got it licked it comes back to haunt me. I started by only loading one record in the form when it opens. This cut 20 to 30 seconds off the load time. I then switched from searching the SSN column via FindRecord to setting the record source in VBA equal to a specific SSN.
Code:
strSQL2 = "Select * FROM Applicant WHERE SSN like '" & InputBox("Social Security #" & vbNewLine & vbNewLine & _
"Use an asterisk (*) to show all.", "Search") & "'"
Set rst2 = CurrentDb.OpenRecordset(strSQL2)
With rst2
If .EOF Then
MsgBox "SSN not found.", vbExclamation
Exit Sub
Else
Me.RecordSource = strSQL2
End If
.Close
This initially worked quite well. In most cases search time went from 30 seconds to 5 or 10 seconds. It would mysteriously take longer in a few cases, but overall performance was much faster. Since the user would have to run this search for each record they were updating, this made a big difference. Just today, after returning from vacation, my very understanding user mentioned to me the search was running slow again. After checking I see that we are very nearly back to square one or worse. When the new RecordSource is specified something odd is happening. Even though the search result shows up almost instantly, the program goes into a long wait. Important to note there is an OnCurrent procedure that is kicked off by this, but the OnCurrent procedure doesn't even start till after the 20 to 30 second wait. The OnCurrent procedure takes only a few seconds to complete. I can't figure out what the system is doing in the mean time since my record already shows on the form.I'm perplexed.