Report based on a filtered form

  • Follow


I need one of my report to show exactly the same records as one of my 
subform. I created a button doing this (which is working) :

DoCmd.OpenReport "00-GetOutstandingSalesOrder", acViewPreview, , 
Form_CustomerOutstandingSalesSubForm.Filter

The problem is if I close my report and remove all filter on the subform 
then click the button again, the last filter is still apply on my report. 
Would like to see all record if there is no filter apply.

My Subform is in datasheet view which I filter using the filters toolbar 
button. I also have a report based on the exact same record source then my 
subform. 

Any suggestion? 

-- 
Yanick
0
Reply Utf 12/15/2009 7:16:01 PM

Yanick wrote:

>I need one of my report to show exactly the same records as one of my 
>subform. I created a button doing this (which is working) :
>
>DoCmd.OpenReport "00-GetOutstandingSalesOrder", acViewPreview, , 
>Form_CustomerOutstandingSalesSubForm.Filter
>
>The problem is if I close my report and remove all filter on the subform 
>then click the button again, the last filter is still apply on my report. 
>Would like to see all record if there is no filter apply.
>
>My Subform is in datasheet view which I filter using the filters toolbar 
>button. I also have a report based on the exact same record source then my 
>subform. 


You should not use the Form_ syntax except when creating
multiple instances of the same form.  Instead, assuming the
name of the subform **control** is named the same as the
form object it displays, use:

With Me.CustomerOutstandingSalesSubForm.Form
	DoCmd.OpenReport "00-GetOutstandingSalesOrder", _
				acViewPreview, , IIf(.FilterOn, .Filter, "")
End With


-- 
Marsh
MVP [MS Access]
0
Reply Marshall 12/15/2009 11:01:46 PM


Marshall,

What is your reason for advising Yanick not to use the "Form_" syntax of 
refering to filter property of a form?  Is this recommendation specific to 
this instance or is there something else involved with this syntax that we 
should all know about?

I've been using the Form_FormName.control for quite some time and have not 
experienced any unforseen circumstances (at least none that I'm aware of).  
The advantage of using that syntax is that you get intellisense.

----
Dale



"Marshall Barton" wrote:

> Yanick wrote:
> 
> >I need one of my report to show exactly the same records as one of my 
> >subform. I created a button doing this (which is working) :
> >
> >DoCmd.OpenReport "00-GetOutstandingSalesOrder", acViewPreview, , 
> >Form_CustomerOutstandingSalesSubForm.Filter
> >
> >The problem is if I close my report and remove all filter on the subform 
> >then click the button again, the last filter is still apply on my report. 
> >Would like to see all record if there is no filter apply.
> >
> >My Subform is in datasheet view which I filter using the filters toolbar 
> >button. I also have a report based on the exact same record source then my 
> >subform. 
> 
> 
> You should not use the Form_ syntax except when creating
> multiple instances of the same form.  Instead, assuming the
> name of the subform **control** is named the same as the
> form object it displays, use:
> 
> With Me.CustomerOutstandingSalesSubForm.Form
> 	DoCmd.OpenReport "00-GetOutstandingSalesOrder", _
> 				acViewPreview, , IIf(.FilterOn, .Filter, "")
> End With
> 
> 
> -- 
> Marsh
> MVP [MS Access]
> .
> 
0
Reply Utf 12/16/2009 9:41:02 PM

Dale Fye wrote:
>What is your reason for advising Yanick not to use the "Form_" syntax of 
>refering to filter property of a form?  Is this recommendation specific to 
>this instance or is there something else involved with this syntax that we 
>should all know about?
>
>I've been using the Form_FormName.control for quite some time and have not 
>experienced any unforseen circumstances (at least none that I'm aware of).  
>The advantage of using that syntax is that you get intellisense.


If there should be multiple instances of a form object (e.g.
the same subform used in more than one place or forms opened
via Set frm New Form_X), Form_ will refer to the default
instance and not to the instance you may think you are
referencing.  The only way I know of to be sure you
reference the instance you intend is to use a specific form
object.  In the case of subforms, the Form property of the
main form's subform control.

-- 
Marsh
MVP [MS Access]
0
Reply Marshall 12/16/2009 10:50:09 PM

Thanks, Marshall.  That is what I thought.

Dale

"Marshall Barton" <marshbarton@wowway.com> wrote in message 
news:d6oii5lne0ckqbn4cuiusduot81oohllve@4ax.com...
> Dale Fye wrote:
>>What is your reason for advising Yanick not to use the "Form_" syntax of
>>refering to filter property of a form?  Is this recommendation specific to
>>this instance or is there something else involved with this syntax that we
>>should all know about?
>>
>>I've been using the Form_FormName.control for quite some time and have not
>>experienced any unforseen circumstances (at least none that I'm aware of).
>>The advantage of using that syntax is that you get intellisense.
>
>
> If there should be multiple instances of a form object (e.g.
> the same subform used in more than one place or forms opened
> via Set frm New Form_X), Form_ will refer to the default
> instance and not to the instance you may think you are
> referencing.  The only way I know of to be sure you
> reference the instance you intend is to use a specific form
> object.  In the case of subforms, the Form property of the
> main form's subform control.
>
> -- 
> Marsh
> MVP [MS Access] 


0
Reply Dale 12/16/2009 11:01:38 PM

4 Replies
255 Views

(page loaded in 0.09 seconds)

Similiar Articles:
















7/17/2012 9:42:11 PM


Reply: