Solved

Re-display modal forms that I have made invi

Posted on 2002-04-23
4
515 Views
Last Modified: 2006-11-17
I am using the following code (I think I got it from this site) to hide all my modal/popup forms. The problem is when there is no data for the report the forms have been hidden and I have no way of making them visible again. How could I call something similar from the no data event of a report that will make the forms visible again.

Help with this is greatly appreciated.

Mandy

Sub OpenReport(ReportName As String, Optional View As Integer, Optional _
    FilterName As String, Optional WhereCondition As String)

Dim loFormArray() As String
Dim loform As Form
Dim intCount As Integer
Dim intX As Integer
   
    ' Hide the modal/ popup or any other open forms
    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 ReportName, View, FilterName, WhereCondition
   
    ' Redisplay the modal/ popup or any other forms that were open
    Do While IsVisible(acReport, ReportName): DoEvents: Loop
    For intX = intCount - 1 To 0 Step -1
        Forms(loFormArray(intX)).Visible = True
    Next
   
    ' Check if the form that called the report module was the calendar view form
    If strCallingForm = "frmCalendarView" Then
        Forms!frmCalendarView.SetFocus
        Exit Sub
    End If
    If strEditForm = True Then
        Forms!frmeditworkdetails.SetFocus
    Else
        Forms!frmreports.SetFocus
    End If
   
End Sub

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
0
Comment
Question by:MandyP1
  • 2
  • 2
4 Comments
 
LVL 1

Expert Comment

by:Lianne072600
Comment Utility
Mandy,

This may not exactly answer your question, but maybe it will help. Have you considered a global variable that holds the name of the last form that was open and then in the no data event of the report you could call the form back up, I am assuming that you have buttons that return you to the other forms i.e when one form is closed it calls the last form in the hierarchy. I know it's not wise to use global variables unless neccessary, but I think in this instance it wouldn't be too problematic.

Hope this helps.

Lianne
0
 

Author Comment

by:MandyP1
Comment Utility
I am not exactly sure what you mean - total newbie, how would I set the variable to the form name?

Mandy
0
 
LVL 1

Accepted Solution

by:
Lianne072600 earned 100 total points
Comment Utility
Hi Mandy, sorry if it seemed like I was ignoring your last comment, ok here goes...

Declare a global variable in a module eg.

Global strFormName As String

Then in the open event of the form set the flag to the name of the form e.g.

Private Sub Form_Open(Cancel As Integer)
    ' Set the flag
    strFormName = Me.Name
    ' The next line just test’s the flag and can be removed once tested
    MsgBox strFlag

End Sub

The global variable can then be used to re-open this form when the NoData event of the report is triggered.

Private Sub Report_NoData(Cancel As Integer)
    MsgBox "There is no data for the current report", vbCritical
    Cancel = True
    DoCmd.OpenForm strFormName

End Sub

You can do this for each form as it opens up, and this will allow the previously opened form to be returned to. Hope this helps.

Lianne
0
 

Author Comment

by:MandyP1
Comment Utility
Thanks. I have played with the code etc you have posted and eventually got this to work.

Mandy
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now