Help with subform errors (1 Viewer)

helper11

Registered User.
Local time
Today, 16:14
Joined
Apr 10, 2010
Messages
40
Hi,

I have the following that runs after a combo box value is selected:

If Not IsNull(Me.Combo3) Then
strSales = "MonthName(Expr3) ='" & Me.Combo3 & "'"

Me.Total_Sales.Form.Filter = strSales
Me.Total_Sales.Form.FilterOn = True

What I want to do is make sure the Me.Total_Sales.Form is not empty, if it is I want to bring up a message box.

I can not find a way to do this that is working. I tried isloaded values and a few other things and nothing worked.

Thanks for any help on this..
 

SOS

Registered Lunatic
Local time
Today, 13:14
Joined
Aug 27, 2008
Messages
3,514
How about this (untested):

Code:
If Not IsNull(Me.Combo3) Then
strSales = "MonthName(Expr3) ='" & Me.Combo3 & "'"

Me.Total_Sales.Form.Filter = strSales
Me.Total_Sales.Form.FilterOn = True
If Me.RecordsetClone.RecordCount = 0 Then
   MsgBox "Something, something"
   Me.Total_Sales.Form.Filter = ""
   Me.Total_Sales.Form.FilterOn = False
End If
 

helper11

Registered User.
Local time
Today, 16:14
Joined
Apr 10, 2010
Messages
40
Hello,

Thank you for the idea. It did not work though, as it said an invalid reference to Recordset. Thanks for your time on this any other ideas would be appreciated?

How about this (untested):

Code:
If Not IsNull(Me.Combo3) Then
strSales = "MonthName(Expr3) ='" & Me.Combo3 & "'"

Me.Total_Sales.Form.Filter = strSales
Me.Total_Sales.Form.FilterOn = True
If Me.RecordsetClone.RecordCount = 0 Then
   MsgBox "Something, something"
   Me.Total_Sales.Form.Filter = ""
   Me.Total_Sales.Form.FilterOn = False
End If
 

SOS

Registered Lunatic
Local time
Today, 13:14
Joined
Aug 27, 2008
Messages
3,514
Sorry, I forgot part of the one piece. We need to make it look for the SUBFORM's recordsetclone:

If Me.YourSubformControl.Form.RecordsetClone.RecordCount = 0 Then

Where YourSubformControl is the name of the control on the main form that houses the subform (and not the name of the subform itself unless the control and subform are named the same).

The .Form. part stays as is because that tells Access you want something on the form itself and not the subform control.
 

helper11

Registered User.
Local time
Today, 16:14
Joined
Apr 10, 2010
Messages
40
Hello,

Thank you so much for the help, that did the trick.

Have a great day...

Sorry, I forgot part of the one piece. We need to make it look for the SUBFORM's recordsetclone:

If Me.YourSubformControl.Form.RecordsetClone.RecordCount = 0 Then

Where YourSubformControl is the name of the control on the main form that houses the subform (and not the name of the subform itself unless the control and subform are named the same).

The .Form. part stays as is because that tells Access you want something on the form itself and not the subform control.
 

SOS

Registered Lunatic
Local time
Today, 13:14
Joined
Aug 27, 2008
Messages
3,514
:) glad to help :)
 

Users who are viewing this thread

Top Bottom