By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,165 Members | 894 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,165 IT Pros & Developers. It's quick & easy.

Custom "No Records Found" Message

P: n/a
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
===
Nov 13 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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
===

Nov 13 '05 #2

P: n/a
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
===

Nov 13 '05 #3

P: n/a
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
Nov 13 '05 #4

P: n/a
One question:

I would like to be able to perform a generic find in a field: in
other words, the user will not always be looking for a given value
each time, but different values every time.

It is possible to code this in VBA?

THANKS!

amy
===
dg*****@yahoo.com (dgs5150) wrote in message news:<52**************************@posting.google. com>...
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

Nov 13 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.