Results 1 to 3 of 3
  1. #1
    Lounger
    Join Date
    Jul 2005
    Location
    Lancaster, Delaware, USA
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Queries (Access 2000/ Windows XP)

    Hello everybody,
    I was wondering if there was a way that when a query returns 0 records that it would pop up a msgbox that lets the user return to the form that performs the query. (I have a form that passes parameters to a query through user intervention) As always any help is very much welcome.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Queries (Access 2000/ Windows XP)

    You can't make a query do that, but you can make the form check if there are records. Say that you have a query qryTest, and a command button cmdAction on the form. The On Click procedure could look like this:
    <code>
    Private Sub cmdAction_Click()
    If DCount("*", "qryTest") = 0 Then
    MsgBox "We regret to inform you that we have no records today.", vbInformation
    Exit Sub
    End If

    ' Rest of code goes here (open query, form, ...)
    ...
    End Sub</code>

  3. #3
    Lounger
    Join Date
    Jul 2005
    Location
    Lancaster, Delaware, USA
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Queries (Access 2000/ Windows XP)

    Thank you Hans. Your code works great. I really appreciate the help. You are "The Man"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •