Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Re-display modal forms that I have made invi

Posted on 2002-04-23
4
Medium Priority
?
553 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 400 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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

609 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