Preview Report when Form is in Modal mode

  • Thread starter Thread starter Simon Webb
  • Start date Start date
S

Simon Webb

I have a form which works in pop up / modal mode as I don't want the
operator to open another form without closing the current one.

The operator can click on a button which produces a report in preview mode,
but the report is 'below' the form and the operator cannot view the report
until the form is closed.

Is there any way that

1) The report is above the form so that the operator can print / export it
2) The operator has to close the report to return back to the form
3) The operator cannot open any other form
4) When the operator returns back to the form it is still modal?

Thanks in advance

Simon Webb
 
I'm not sure that this is a good idea or even practical.
In the "view report button" click event put Forms!Mypopupform.visible=False
In the reports close event put Forms!Mypopupform.visible=True
Substitute your form name for Mypopupform
 
I have a form which works in pop up / modal mode as I don't want the
operator to open another form without closing the current one.

A possible solution here is to remove the popup setting of your forms. There
is NO reason to use popup setting here, as model should be sufficient to
keep the current form on top. If a model form opens another model form, then
again, that form stays on top, ad you MUST close the form to go back the way
you came. This process can be 4, or 5 forms deep, but the user will ALWAYS
have to close the forms in the order they were opened.

The above should done with model forms, but NOT the popup setting. The popup
setting would allow you to display a form on top of everything,a and remains
on top. (even if you opened 5 forms model..and are thus forced to close
those 5 models forms, all the while the popup form would remain on top.
Thus, popup is to be used for wizard type interface, or sometimes a "helper"
type screen that you need to remain on top at ALL TIMES.

These popup will also remain on top of report.

Since you made no arguments as to you needing the popup setting, then I
would simply dump that seating.

It is quite clear that you need the model setting to force the user back the
way they came to the previous forms, but you don't need the popup setting...
 
Hi Simon, may be this code can help you
Paste all in a new module:
'Beginning of code
Option Compare Database
Option Explicit
Enum mViewReport
facViewDesign = 1
facViewNormal = 0
facViewPreview = 2
End Enum

Function fOpenReport(mReportName As String, _
Optional mView As mViewReport = 2, _
Optional mFilterName As String = "", _
Optional mWhereCondition As String = "", _
Optional mOpenArgs As String = "")

Dim loFormArray() As String
Dim loform As Form
Dim intCount As Integer
Dim intX As Integer
For Each loform In Forms
If loform.Visible Then
ReDim Preserve loFormArray(intCount)
loFormArray(intCount) = loform.Name
loform.Visible = False
intCount = intCount + 1
End If
Next
DoCmd.OpenReport mReportName, mView, mFilterName, mWhereCondition
Do While IsVisible(acReport, mReportName): DoEvents: Loop
For intX = intCount - 1 To 0 Step -1
Forms(loFormArray(intX)).Visible = True
Next
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

Now, always you open a report must be use the previous function fOpenReport,
have the same arguments of the DoCmd.OpenReport but resolve your problem, let
me know if have another question about this.

P.D. Code found in www.mvp-access.com the Buho home page, and I only add the
Enum section
 
Back
Top