Re: Test for no records returned

From: Cheryl Fischer (cherylfischer_at_NOSPAMmsn.com)
Date: 04/30/04


Date: Thu, 29 Apr 2004 21:40:51 -0500

To add to Tina's post, if you want to test a query being used as the Record
Source of a form, you can put the following code in the Open event of the
form:

If Me.RecordsetClone.RecordCount = 0 Then
   MsgBox "There are no records to review."
   Cancel = True
End If

If there are no records in the query, the form does not open and the message
box is displayed for the user.

--
Cheryl Fischer, MVP Microsoft Access
Law/Sys Associates, Houston, TX
"Brian C" <anonymous@discussions.microsoft.com> wrote in message
news:640d01c42e42$3f3195f0$a301280a@phx.gbl...
> If I run a select query that may return no records how do
> I test that there are no records?
>
> I need to do this in code, i.e.code a select statement
> followed by the test. Thanks in advance.


Relevant Pages

  • Re: Input Text into fields with query
    ... Post the SQL for the query you are trying to run. ... >>Cheryl Fischer, MVP Microsoft Access ...
    (microsoft.public.access.queries)
  • Re: Importing with the right format conversion
    ... You can update more than one field in an Update Query. ... >>use yyyymmdd format so that you do not have to write ... >>Cheryl Fischer, MVP Microsoft Access ...
    (microsoft.public.access.externaldata)
  • Re: Unable to Change Data on Form
    ... How about posting the SQL code for your query so we can see if there is a ... >>A couple of possibilities come to mind, Sharon ... ... >>Cheryl Fischer, MVP Microsoft Access ...
    (microsoft.public.access.formscoding)
  • RE: AllowAdditions
    ... The only code I have is on the Open event ... to dispaly another form to prompt the user for query parameters. ... Could this be related to the original problem? ... and the AllowDeletions and AllowAdditions properties set to No. ...
    (microsoft.public.access.forms)
  • Re: Leap Year Date Problem
    ... Cheryl Fischer, MVP Microsoft Access ... "Cathy" wrote in message ... > I have a query where included in the select statement I ...
    (microsoft.public.access.queries)