Solved

Re-display modal forms that I have made invi

Posted on 2002-04-23
4
533 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
[X]
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
  • 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

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…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

696 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