Hiding a window when a report opens

I want users to select a filter criteria on a form (Main Menu), hide the form 
and open a report maximized.  It worked well with slightly modified code and 
in other forms that I have used, but I am at a loss on how to get it to work. 
 It opens the report fine, but then the form shows up on top with a 
non-maximized report in a second window.  The report filters correctly.

    Dim stLinkCriteria As String

    If (Forms![Main Menu]!AcctBreakout = 1) Then
        DoCmd.RunCommand acCmdWindowHide
        stLinkCriteria = "[All Data].Projsub= " & [Field5]
        DoCmd.OpenReport "By Line Item2", acViewPreview
        Reports![By Line Item2].Filter = stLinkCriteria
        DoCmd.Maximize

    End If


End Sub

0
Utf
12/29/2007 11:05:01 PM
access.formscoding 7493 articles. 0 followers. Follow

3 Replies
919 Views

Similar Articles

[PageSpeed] 13

This is how I would do it, then on the open statement of your report,
add DoCmd.Maximize

   =A0 =A0 Dim stLinkCriteria As String
       Dim stReport As String

       stLinkCriteria =3D "[All Data].Projsub=3D " & [Field5]
       stReport =3D "By Line Item2"

 =A0 =A0
       If (Forms![Main Menu]!AcctBreakout =3D 1) Then
   =A0 =A0 DoCmd.RunCommand acCmdWindowHide
 =A0 =A0 =A0 DoCmd.OpenReport stReport, acViewPreview, stLinkCriteria
     =A0 End If

End Sub

0
magmike
12/29/2007 11:19:01 PM
Hi Scott,
one thing to check is the form's popup property.
If the form has its pop up property set to yes, it will open on top.

Jeanette Cunningham


"scott" <scott@discussions.microsoft.com> wrote in message 
news:18AA7FFD-34AE-485E-82FB-4A89F50BC62F@microsoft.com...
>I want users to select a filter criteria on a form (Main Menu), hide the 
>form
> and open a report maximized.  It worked well with slightly modified code 
> and
> in other forms that I have used, but I am at a loss on how to get it to 
> work.
> It opens the report fine, but then the form shows up on top with a
> non-maximized report in a second window.  The report filters correctly.
>
>    Dim stLinkCriteria As String
>
>    If (Forms![Main Menu]!AcctBreakout = 1) Then
>        DoCmd.RunCommand acCmdWindowHide
>        stLinkCriteria = "[All Data].Projsub= " & [Field5]
>        DoCmd.OpenReport "By Line Item2", acViewPreview
>        Reports![By Line Item2].Filter = stLinkCriteria
>        DoCmd.Maximize
>
>    End If
>
>
> End Sub
> 


0
Jeanette
12/29/2007 11:47:52 PM
Thanks.  This worked, but I had to remove the stLinkCriteria from the 
OpenReport command and put back in the Report Filter command.  The report 
would not filter records when stLinkCriteria was used as a where clause in 
the Open Report command (a syntax thing?).

I guess the trick was to put the maximize command in the Open Form 
statement.  I'm not sure why that would be and I'm pretty sure I have used 
the same command in other forms that I have used.

In any case, thanks a lot.

For Jeannette - the popup was set to no.

"magmike" wrote:

> This is how I would do it, then on the open statement of your report,
> add DoCmd.Maximize
> 
>        Dim stLinkCriteria As String
>        Dim stReport As String
> 
>        stLinkCriteria = "[All Data].Projsub= " & [Field5]
>        stReport = "By Line Item2"
> 
>     
>        If (Forms![Main Menu]!AcctBreakout = 1) Then
>        DoCmd.RunCommand acCmdWindowHide
>        DoCmd.OpenReport stReport, acViewPreview, stLinkCriteria
>        End If
> 
> End Sub
> 
> 
0
Utf
12/30/2007 1:14:00 AM
Reply:

Similar Artilces: