Filtering a Subform (1 Viewer)

ECEK

Registered User.
Local time
Today, 16:36
Joined
Dec 19, 2012
Messages
717
Just struggling with the VBA reference.

My Main form is based around a table with one entry "Quarter"
My sub form is linked to show only the data with the same "Quarter"

I then need to filter my (datasheet) subform by status.

I want a command button that filters the subform by "to be actioned" in the status field.
If the data was on the same form I would use:

DoCmd.ApplyFilter , "status = 'to be actioned'"

How do I reference the subform from the main form?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 00:36
Joined
May 7, 2009
Messages
19,169
use the Click Event of the button:

Code:
Private Sub yourButton_Click()
	DoCmd.ApplyFilter ,"[status]='to be actioned'", "yourSubFormName"
End Sub
 

CJ_London

Super Moderator
Staff member
Local time
Today, 16:36
Joined
Feb 19, 2013
Messages
16,553
had forgotten abut that way of doing it - but shouldn't that be "yourSubFormControlName"?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 00:36
Joined
May 7, 2009
Messages
19,169
there is error when using ControlName.
although the error message says that i should put the controlname on the subform or report.
this message is misleading.
using subform name correct the problem.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 16:36
Joined
Feb 19, 2013
Messages
16,553
so what worked for you in the end? other users may find your solution helpful
 

ECEK

Registered User.
Local time
Today, 16:36
Joined
Dec 19, 2012
Messages
717
Hi Guys I used CJ's solution.

me.nameofsubformcontrol.form.filter= "status = 'to be actioned'"
me.nameofsubformcontrol.form.filteron=true
 

Users who are viewing this thread

Top Bottom