Open form with filter

Lloyd

Registered User.
Local time
Today, 02:13
Joined
Sep 6, 2005
Messages
16
I have a simple bit of code below but I need something added. All the code is doing is opening a form and filtering on a combo box value. It opens all cases where the status is open but if there are no open cases it takes me to a new record, how do I get my code to recognise that there are no cases and display a message box for me instead and then close the form?

Private Sub open_Click()

Dim stDocname As String

stDocname = "frmMain"

DoCmd.OpenForm stDocname
DoCmd.ApplyFilter , "Status ='Open"

End Sub
 
Could you do an if statement using a dcount() function to see if any records exist and open the form only if the dcount() returns a value >0?
 
Maybe but I am beginner so am not capable, could you write it?

cheers
 
How about you go to VBA help and look at the dcount() function. If you need help at that point, post back and I'll see what I can do to help.... :)
 

Users who are viewing this thread

Back
Top Bottom