Solved

Re-display modal forms that I have made invi

Posted on 2002-04-23
4
524 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
ID: 7009357
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
ID: 7011150
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
ID: 7073993
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
ID: 7083289
Thanks. I have played with the code etc you have posted and eventually got this to work.

Mandy
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Access query expression 6 20
Change date stored as "short text" YYYYMMDD to MM/DD/YYYY? 27 27
Access Delete Query Not Working 13 28
Switch 5 16
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
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…

772 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