Object Variable or with block variable not set - Help

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
 
M

Mark Sippitt

Hi,

Try replacing the line:

Dim Reccheck As Recordset

With

Dim Reccheck As New Recordset

Hope this helps
Mark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top