Report preview problem

S

Sunny

I have a one mainmenu form with 5 command button showing differnt report
options, if user press any of button this form should hide and parameter
form should open. On parameter form I have two button <ProcessReport> and
<Exit>, If user press ProcessButton, this form should hide and report should
open in preview mode. (In this case mainmenu and parameter I should have 2
forms hide). Once user close the report parameter form should show up (Still
mainmenu form should remain hide). When user close the parameter form or
clicked on exit button, mainmenu form should shoup.

Can anyone give me idea what to do to setup this way?

Thanks.
 
L

Larry Linson

Where frmM is the mainmenu, frmP is the parameter form, and rptR is the
report:

In the Click event of the Command Button on mainmenu:

DoCmd.OpenForm "frmP"...
DoCmd.Close

In the Click event of the Command Button on frmP

DoCmd.OpenReport "rptR" ...
DoCmd.Close

In the Close event of the Report

DoCmd.OpenForm "frmP"...

In the Click event of the Exit button on frmP

DoCmd.OpenForm "frmM"...

But, if neither of the forms is a PopUp or Dialog, and they really do not
need to be, you can omit the opening and closing... the frmP will open on
top of frmM, rptR will open on top of frmP, when rptRcloses, frmP will be
revealed, and when frmP closes, frmM will be revealed. But, it would be
possible for a user to move around in the windows with Alt-Tab or the Window
menu item, if that is a concern.

Larry Linson
Microsoft Access MVP
 
K

Kelvin

Just move the focus to the correct object before trying to open and close
forms.
1) For each button on the mainmenu form add code to minimize the form first
then open the parameter form.
DoCmd.Minimize
DoCmd.OpenForm "frmParameter"
2) On the ProcessReport button minimize the current form and open the report
DoCmd.Minimize
DoCmd.OpenReport "rptReport"
3) On the OnClose event of the report restore the parameter form
Forms!frmParameter.Setfocus
DoCmd.Restore
4) On the exit button of the parameter form
Forms!frmMainMenu.Setfocus
DoCmd.Restore

You might want to add error checking to make sure the form is open.

Kelvin
 
S

Sunny

Thanks Larry and Kelvin.

It works but I tried one another way, someone might be intereste.

1.Code in click event of mainmenu form
Me.Visible = False
DoCmd.OpenForm 'ParaForm', acNormal, , , , acDialog
Do While IsVisible(acForm, 'ParaForm'): DoEvents: Loop
Me.Visible = True

2. Code in click event of OK button on ParaForm
Me.Visible = False
DoCmd.OpenReport "MyReport", acViewPreview, , , acWindowNormal, MyArgu
Do While IsVisible(acReport, "MyReport"): DoEvents: Loop
Me.Visible = True

3. Code in Click event of Exit button on ParaForm
DoCmd.Close acForm, Me.Name

4. Code in Close event of MyReport
If IsOpen("ParaForm") Then
Forms("ParaForm").Visible = True
End If


Function IsOpen(strName As String, _
Optional intType As AcObjectType = acForm)
' Is the form open?
IsOpen = (SysCmd(acSysCmdGetObjectState, intType, strName) <> 0)
End Function

Function IsVisible(intObjType As Integer, strObjName As String) As Boolean
Dim intObjState As Integer
intObjState = SysCmd(acSysCmdGetObjectState, intObjType, strObjName)
IsVisible = intObjState And acObjStateOpen
End Function
 

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