• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 251
  • Last Modified:

storing a variable and filtering a report from a closed form

Hi everyone,

I have a Access 2010 DB based on a MS Sales Pipeline template.  The print button on the form is set to check the form for dirty, save it, close it, and open a report based on the [ID] which was set prior to the form closing.

What I can't understand is why MS coded it this way as I can't see how the variable for the filter gets to the report if the form is closed. I took out the close comman and now the filter is set correctly, however as the forms are pop up, the reports are behind the form.

Can a filter criteria be passed to a report if the form is closed before the report opens?

If the form is Pop Up, can the form be made to fall back when the report is run?

In general, what is the best way to handle reports arising from reports and how to handle the windows.  I didn't see a window mode...only pop up.

Thanks,
0
MCinOH
Asked:
MCinOH
  • 4
  • 2
1 Solution
 
mbizupCommented:
If you set the criteria in your open report statement, the form does not need to be open when the report runs.  Like this:

Docmd.OpenReport "yourReportName", acviewpreview,, "[ID] = " & me.ID
0
 
mbizupCommented:
In otherwords, set the criteria in the OpenRport statement, rather than the report's recordsource.
0
 
MCinOHAuthor Commented:
I agree.  What you describe is how the form is set up now in the Macro.

I select the record, click print and this is how the Macro runs.

Close the Form.

UserInterfaceMacro For="cmdPrint" Event="OnClick"><Statements><Action Name="CloseWindow"/></Statements></UserInterfaceMacro></UserInterfaceMacros>

Open the report and set the filter.

cmdPrint" Event="OnClick"><Statements><Action Collapsed="true" Name="OpenReport"><Argument Name="ReportName">Opportunity Details</Argument><Argument Name="View">Print Preview</Argument><Argument Name="WhereCondition">="[ID]=" &amp; [ID

I just can't get this to work when the form is closed.  If I remove the close statement from the Macro, the report filters correctly.   How is the [id] filter criteria passed to the report if the form is closed?
0
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 
mbizupCommented:
Reverse the order of the statements.

First open the report
Then close the form (the form does not need to remain open if the report has no references to it)

In VBA, if would look like this:

Docmd.Open report "rptReportName" ...
Docmd.Close acform, me.Name

The form closure is immediate, so the visual effect should be what you are looking for.
0
 
MCinOHAuthor Commented:
I figured out the same thing. I was so set on the fact the MS must know something I didn't about passing criteria to reports that I didn't challenge it. Thanks again.
0
 
mbizupCommented:
Ha!  Don't sell yourself short like that.

After playing around with a few sample DBs and templates like that, you'll find that they do often teach you good table design, but that the UIs are frequently thrown together quickly for the purpose of showing you a variety of features while teaching you something about table design.

The best/most efficient UIs are going to be the ones that you come up with independently after exceeding the limitations of those templates.
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now