Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Re-display modal forms that I have made invi

Posted on 2002-04-23
4
529 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
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…

829 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