Object Variable or with block variable not set - Help

  • Thread starter Thread starter Victor
  • Start date Start date
V

Victor

Hi,
Here is a piece of code I am trying to write in Access
2000. I keep getting "Object Variable or with block
variable not set" error, when the program hits
"set Reccheck" line. Please help.

Private Sub BtnFind_Click()
On Error GoTo Err_BtnFind_Click

Dim Reccheck As Recordset

Fname.SetFocus

If Fname.Text <> " " Then
Set Reccheck = CurrentDb.OpenRecordset("Select *
from Applicants WHERE FirstName like '" & Fname.Text & "
*'")
If Reccheck.RecordCount > 0 Then
Me.RecordSource = "select * from applicants where
firstname = '" & Fname.Text & " *'"
Me.Requery
Else
MsgBox "No Records Found"
End If
Set Reccheck = Nothing
End If

Exit_BtnFind_Click:
Exit Sub

Err_BtnFind_Click:
MsgBox Err.Description
Resume Exit_BtnFind_Click

End Sub
 
Hi,

Try replacing the line:

Dim Reccheck As Recordset

With

Dim Reccheck As New Recordset

Hope this helps
Mark
 
Back
Top