Hiding a window when a report opens

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
 
M

magmike

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
 
J

Jeanette Cunningham

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
 
S

scott

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top