No data on filtered form - prevent from opening?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I have an order form with a line item subform with a returns subform on the
line item subform. I also have a button on the main order form that will
switch to a sort of "summary" form (based on a query) that displays all
returns against a particular order (through a filter).
Is there a way to display a message box, or even prevent the summary form
from opening, if there are no records to display? I tried fooling around a
little bit with the open and load events of the summary form, but I couldn't
get anything to work.

Thanks in advance.
 
try adding the following to the summary form's Open event, as

Private Sub Form_Open(Cancel As Integer)

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

End Sub

hth
 
Back
Top