Show message box if no records in the form

I have a form that I open with criteria so it is filtered.  I would like to have a message appear if there are no records to display.  How can I count the number of records when the form opens and then display a message if the number is 0?

Thanks.
beyondtAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Helena Markováprogrammer-analystCommented:
You can use
Select count(*) INTO <<your_variable>> from <<tables with your criteria>>
and display this your_variable in a message box.

In Oracle Forms it will be:
When-New-Form-Instance trigger :
Declare
  your_variable  PLS_INTEGER;
BEGIN
 Select count(*) INTO your_variable FROM ....;
 IF your_variable=0 THEN
   Message('There are no records there.');
   Message('There are no records there.');
 END IF;
END;
0
Alan WarrenApplications DeveloperCommented:
Hi beyondt

if MS Access something like this may do.

Private Sub Form_Current()
  If Me.RecordsetClone.RecordCount = 0 Then
    MsgBox Me.RecordsetClone.RecordCount
  End If
End Sub


Alan
0
dragonfire123Commented:
Maybe it would help us understand the problem better if we knew how you're accessing the database, and what language (or platform) you're using to get at the data?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Databases

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.