dicepackage
09-07-2011, 07:02 AM
I have a function below to search for the last name of someone and go to the most recent ID with that name. The problem is that these searches can take a long time since I have so many records (around 700k and growing).
I would like to run this function but automatically quit after 20 seconds if it is not found within that time. Typically if it doesn't find something right away it will not find anything at all. Is there anyway to run a piece of code and automatically break if the time limit is exceeded?
Dim rsForm As DAO.Recordset
Set rsForm = Forms!Main.RecordsetClone
With rsForm
.FindLast "[LASTNAME] = " & Chr(34) & Me.TextSearch & Chr(34)
End With
If rsForm.NoMatch = True Then
MsgBox "Not found", vbExclamation, "Error"
Else
Forms!Main.Bookmark = rsForm.Bookmark
I would like to run this function but automatically quit after 20 seconds if it is not found within that time. Typically if it doesn't find something right away it will not find anything at all. Is there anyway to run a piece of code and automatically break if the time limit is exceeded?
Dim rsForm As DAO.Recordset
Set rsForm = Forms!Main.RecordsetClone
With rsForm
.FindLast "[LASTNAME] = " & Chr(34) & Me.TextSearch & Chr(34)
End With
If rsForm.NoMatch = True Then
MsgBox "Not found", vbExclamation, "Error"
Else
Forms!Main.Bookmark = rsForm.Bookmark