Window Sizing Question

G

Guest

Using WinXP and Access 2002

On a main form (maximized) I have a button that opens an e-mail form. On the
e-mail form, I have a button that will 'preview' a report before it is sent
in the e-mail. The e-mail form opens 'maximized'. When I close the 'preview'
of the report, the screen reverts to 'restore' size of the e-mail form
instead of 'maximized'.

I'm thinking that there must be a way to maximize the screen when I close
the report preview.

Thanks in advance.
 
A

Arvin Meyer [MVP]

Jim Ory said:
Using WinXP and Access 2002

On a main form (maximized) I have a button that opens an e-mail form. On the
e-mail form, I have a button that will 'preview' a report before it is sent
in the e-mail. The e-mail form opens 'maximized'. When I close the 'preview'
of the report, the screen reverts to 'restore' size of the e-mail form
instead of 'maximized'.

I'm thinking that there must be a way to maximize the screen when I close
the report preview.

Thanks in advance.

Put this in the report's close event:

Private Sub Report_Close()
DoCmd.Maximize
End Sub

--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access
 
L

Larry Daugherty

lookup the Maximize Action in Help.

Put a maximize command in the line just below the one in which you
call the Preview.

HTH
 
G

Guest

I thought that would solve the size problem too, but the forms are all in
'restore' size behind the 'preview' and won't maximize on report close.
 
G

Guest

Arvin, I thought that maybe I hadn't set focus to the form, so I added:
docmd.selectobject acform, "formname", true
then your suggestion:
docmd.maximize

That didn't work either, but I can get it to work with a macro in the close
event of the report preview. Am I missing some code perhaps?
 
H

Harley Feldman

I have exactly the same symptoms and problems as Jim. After the
DoCmd.OpenReport [ReportName],acPreview, I added DoCmd.Maximize. This code
does not work as Access has taken the form calling the preview function and
not only minimized it, but it has grayed out the maximize icon. I assume
that calling DoCmd.Maximize has no effect in that case. I cannot figure out
why Access grays out the maximize button in the first place.

Harley
 
L

Larry Daugherty

The following works for me. The docmd.maximize was put in to handle
just the situation you describe.


On Error GoTo cmdSortByDate_Click_Err
Dim strErrMsg As String 'For Error Handling

Dim DocName As String

DocName = "rptLineCountSortedbyDate"
DoCmd.OpenReport DocName, IIf(Me![optPrintOrPreview] = 1,
A_NORMAL, A_PREVIEW)

DoCmd.Maximize

cmdSortByDate_Click_Exit:
On Error Resume Next
Exit Sub


HTH
 
H

Harley Feldman

I found the following two lines of code in the Close Event of the preview
report solves the problem:

DoCmd.SelectObject acForm, "YourFormName"
DoCmd.Maximize

This code makes sure that the correct form is selected before issuing the
maximize.

The downside is that if you open the main database window, and then go back
to the form, it is minimized along with the main Access window. There must
be a setting that Access is remembering for the main window. Any ideas on
how to maximize the main window or prevent it from minimizing?

Harley
 
G

Guest

In the close event of the report:

Private Sub Report_Close()
On Error GoTo Err_Handler

DoCmd.SelectObject acForm, "frmemailreport"
DoCmd.Maximize

Exit_Handler:
Exit Sub

Err_Handler:
If Err.Number <> 2489 Then
MsgBox Err.Number & ": " & Err.Description
End If
Resume Exit_Handler
End Sub

This is working fine for me.
 
G

Guest

Arvin,
Thanks for the code. I actually tried that and it works for previewing the
report opened from a form control. But, if I'm working on the report that was
called without the form being open, like from the Access window or from a
different form control, then I get two screens of errors on close because the
macro wants a particular form to be open.

From all the help I've been given, and I do appreciate all of it, I added
'error trapping', another hint from MVPs. The following code looks like this:

In the close event of the report:

Private Sub Report_Close()
On Error GoTo Err_Handler

DoCmd.SelectObject acForm, "frmemailreport"
DoCmd.Maximize

Exit_Handler:
Exit Sub

Err_Handler:
If Err.Number <> 2489 Then
MsgBox Err.Number & ": " & Err.Description
End If
Resume Exit_Handler
End Sub

This works for all my situations and I use it in all of my reports.
--
Jim Ory


Arvin Meyer said:
It works on my machine. Try seeing if you can run the macro from code in
that event:

DoCmd.RunMacro MacroName
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access

Jim Ory said:
Arvin, I thought that maybe I hadn't set focus to the form, so I added:
docmd.selectobject acform, "formname", true
then your suggestion:
docmd.maximize

That didn't work either, but I can get it to work with a macro in the close
event of the report preview. Am I missing some code perhaps?
--
Jim Ory


Arvin Meyer said:
"Jim Ory" <jim[at]oryfamilyhistory[dot][comma]> wrote in message
Using WinXP and Access 2002

On a main form (maximized) I have a button that opens an e-mail form. On
the
e-mail form, I have a button that will 'preview' a report before it is
sent
in the e-mail. The e-mail form opens 'maximized'. When I close the
'preview'
of the report, the screen reverts to 'restore' size of the e-mail form
instead of 'maximized'.

I'm thinking that there must be a way to maximize the screen when I close
the report preview.

Thanks in advance.

Put this in the report's close event:

Private Sub Report_Close()
DoCmd.Maximize
End Sub

--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access
 

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

Similar Threads


Top