Hiding a window when a report opens

  • Thread starter Thread starter scott
  • Start date Start date
S

scott

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
 
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
 
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
 
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.
 
Back
Top