am*******@verizon.net (amywolfie) wrote in message news:<33*************************@posting.google.c om>...
I'm having problems with the recordset. The code below is not working:
Function NoRecordsFound()
On Error GoTo Error_Handler:
Set frm = Forms("frmFeeInput")
RecordsetClone.FindFirst
If (frm.RecordsetClone.RecordCount) = 0 Then 'this is where it dies
MsgBox "Record Not Found!"
Else
frm.Bookmark = frm.RecordsetClone.Bookmark
frm.SetFocus
End If
Exit Function
Error_Handler:
MsgBox Err.Description & Err.Number
End Function
=====
Thanks!
amy
===
"PC Datasheet" <no****@nospam.spam> wrote in message news:<8D******************@newsread3.news.atl.eart hlink.net>... Assuming you are using a recordset for the Find, use the following code:
If Rst.NoMatch Then
MsgBox "No Records Found"
End If
--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com
"amywolfie" <am*******@verizon.net> wrote in message
news:33**************************@posting.google.c om... I would like to put code behind a Find button on a form which:
1) Performs a find based on a field on the form
2) If NO RECORDS ARE FOUND, then displays a custom "No Records Found" message box.
Thanks!!
amy
===
The code you posted has a findfirst but no arguments after the find
first. If you look at help on find first you will see criteria is
required.
A String used to locate the record. It is like the WHERE clause in an
SQL statement, but without the word WHERE
Also the frm.recordsetclone.recordcount = 0 is incorrect for the form
data source more than likely has at least 1 record. You need ot use
frm.RecordsetClone.NoMatch = True to evaluate if a record was found
On Error GoTo Error_Handler:
Dim frm As Form
Set frm = Forms("form1")
RecordsetClone.FindFirst ("test = 'a'")
If (frm.RecordsetClone.NoMatch) = True Then 'this is where it dies
MsgBox "Record Not Found!"
Else
frm.Bookmark = frm.RecordsetClone.Bookmark
frm.SetFocus
End If
Exit Sub
Error_Handler:
MsgBox Err.Description & Err.Number