if query returns none, do not open form

glrs430

New Member
Joined
Nov 2, 2004
Messages
6
Hi,

I'm new to access and am in need of some help.

I have a search window that will open a form and display searched results. However, I would like it NOT to open the form when there are no results from the query. Instead, I would like to have a pop-up informing user that there is no result based on their search criteria.

Thanks,
Gina
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
This goes in your form that displays your search results...

Code:
Private Sub Form_Load()
    If Me.Recordset.EOF Then
        MsgBox ("No Records Returned")
        DoCmd.Close
    End If
End Sub
 
Upvote 0
Thanks for getting back to me.

Do I need to declare Me.Recordset? I included the code as is and Access 97 is giving me a compile error, indicating that it doesn't recognize Me.Recordset.

Thanks,
Gina
 
Upvote 0
Gina

You might want to take a look at DCount.

You could use this to tell you if there are any records based on your criteria and then open/not open the form accordingly.

How are you currently opening the form and what exactly is your 'search window'?
 
Upvote 0

Forum statistics

Threads
1,214,585
Messages
6,120,394
Members
448,957
Latest member
Hat4Life

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top