sign in | join about | help | sitemap
Connecting Tech Pros Worldwide
Deano's Avatar

a2k - my solution to opening reports modally - comments?


Question posted by: Deano (Guest) on November 12th, 2005 04:47 PM
I've been mulling over how to prevent users from clicking back onto my form
after they have run a report. I want them to close the report first.

The simple solution which I have tested successfully is simply to hide the
calling form and make is visible again in the Close event of the report.
Seems fine to me but can anyone see any flaws in this?


3 Answers Posted
Allen Browne's Avatar
Guest - n/a Posts
#2: Re: a2k - my solution to opening reports modally - comments?

Hiding the form will probably do all you need.

In Access 2002 and 2003, you can open a report modally if you need to:
DoCmd.OpenReport "MyReport", WindowMode:=acDialog

An underlying issue is why the form needs to be open and not changed?
If the report is dependent on the form in some way, you may be able to avoid
that by reading the values from the form in the Report Header secton's
Format event, and assigning the values to unbound controls on the report,
instead of binding those controls to an expression that looks at the form.

Alternatively, if the problem is that the user flicks back to the form and
hits the your OpenReport command button again which does not filter the
report correctly, you may want to code to close the report and reopen it:
strDoc = "MyReport"
If SysCmd(acSysCmdGetObjectState, acReport, strDoc) = 1 Then
DoCmd.Close acReport, strDoc
End If
DoCmd.OpenReport strDoc

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Deano" <deanma66999@hotmail.com> wrote in message
news:3bUvb.11921$lm1.86142@wards.force9.net...[color=blue]
> I've been mulling over how to prevent users from clicking back onto my[/color]
form[color=blue]
> after they have run a report. I want them to close the report first.
>
> The simple solution which I have tested successfully is simply to hide the
> calling form and make is visible again in the Close event of the report.
> Seems fine to me but can anyone see any flaws in this?[/color]


Deano's Avatar
Guest - n/a Posts
#3: Re: a2k - my solution to opening reports modally - comments?

Allen Browne wrote:[color=blue]
> Hiding the form will probably do all you need.
>
> In Access 2002 and 2003, you can open a report modally if you need to:
> DoCmd.OpenReport "MyReport", WindowMode:=acDialog
>
> An underlying issue is why the form needs to be open and not changed?[/color]

Good question. Well I'm in a testing phase at the moment and I did notice
yonks ago that I experienced a lockup/crash if I left a report open and then
merrily switched forms.
Basically I have a form that allows various reports to be run and and when
the user exits this form, I think it's reasonable that they have closed the
reports down.
It also looks less confusing, and given the ability of my users I think any
opportunity to stop them confusing themselves should be embraced :)
[color=blue]
> If the report is dependent on the form in some way, you may be able
> to avoid that by reading the values from the form in the Report
> Header secton's Format event, and assigning the values to unbound
> controls on the report, instead of binding those controls to an
> expression that looks at the form.[/color]

Thanks for that tip.
[color=blue]
>
> Alternatively, if the problem is that the user flicks back to the
> form and hits the your OpenReport command button again which does not
> filter the report correctly, you may want to code to close the report
> and reopen it: strDoc = "MyReport"
> If SysCmd(acSysCmdGetObjectState, acReport, strDoc) = 1 Then
> DoCmd.Close acReport, strDoc
> End If
> DoCmd.OpenReport strDoc[/color]

Thanks again.
[color=blue]
>
> "Deano" <deanma66999@hotmail.com> wrote in message
> news:3bUvb.11921$lm1.86142@wards.force9.net...[color=green]
>> I've been mulling over how to prevent users from clicking back onto
>> my[/color]
> form[color=green]
>> after they have run a report. I want them to close the report first.
>>
>> The simple solution which I have tested successfully is simply to
>> hide the calling form and make is visible again in the Close event
>> of the report. Seems fine to me but can anyone see any flaws in this?[/color][/color]



David W. Fenton's Avatar
Guest - n/a Posts
#4: Re: a2k - my solution to opening reports modally - comments?

Join Bytes! (Deano) wrote in
<QJUvb.11924$lm1.86272@wards.force9.net>:
[color=blue]
>Well I'm in a testing phase at the moment and I did notice
>yonks ago that I experienced a lockup/crash if I left a report
>open and then merrily switched forms.
>Basically I have a form that allows various reports to be run and
>and when the user exits this form, I think it's reasonable that
>they have closed the reports down.[/color]

In the UnLoad event of your reports form, do this:

Dim rpt As Report

For each rpt in CurrentDB.Reports
DoCmd.Close acReport, rpt.Name
Next rpt

Set rpt = Nothing

This will cycle through all open reports and close them.

You could also have this happen in the OnActivate event of the form
if you want to close reports when the user gets back to your
reports form.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
 
Not the answer you were looking for? Post your question . . .
196,916 members ready to help you find a solution.
Join Bytes.com

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 196,916 network members.
Post your question now . . .
It's fast and it's free

Popular Articles

Top Community Contributors