Show message box if no records in the form

Posted on 2004-11-08
Last Modified: 2008-01-16
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?

Question by:beyondt
    LVL 22

    Expert Comment

    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 :
      your_variable  PLS_INTEGER;
     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;
    LVL 26

    Expert Comment

    by:Alan Warren
    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

    LVL 1

    Accepted Solution

    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?

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Introduction After workin in a plethora of programming languages like C, Pro*C, ESQL/C, C++, VC++, VB, Java, HTML,JavaScipt etc, technologies and frameworks like JSP, Servlets, Struts, Spring, IBatis etc and databases like MS Access, SQLServer, Inf…
    Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
    Video by: Steve
    Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now