This is searching through a table of ~10,000 records to find whether the user-entered project# already exists, and populate the form if it does. I don't want to use a bound form here, with that in mind is this the most efficient way of searching through the ProjID field? thanks!
Code:
Private Sub Project_Number_LostFocus()
Dim intProj As Integer
Dim rs As Recordset
Dim db As Database
Dim match As String
Set db = CurrentDb
intProj = Me.Project_Number
Set rs = db.OpenRecordset("dbo_tblProj")
Me.lbSearching.Visible = True
DoEvents
rs.MoveFirst
Do Until match = "True" Or match = "Limit"
Select Case rs("ProjID").Value = intProj
Case Is = True
With Forms!frm_Create_Project
.Project_Description = rs("ProjComments")
.Address = rs("ProjAddrLine1")
.City = rs("ProjCity")
.State = rs("ProjState")
.Zip = rs("ProjZip")
.County = rs("ProjCounty")
End With
match = True
rs.Close
Case Is = False
With Forms!frm_Create_Project
.Project_Description = ""
.Address = ""
.City = ""
.State = ""
.Zip = ""
.County = ""
End With
If rs("ProjID") > intProj Then match = "Limit"
rs.MoveNext
End Select
Loop
Me.lbSearching.Visible = False
End Sub