[AccessD] How to Show a Specific Report at Initiation Time(When there is also a default form)

William Benson (VBACreations.Com) vbacreations at gmail.com
Tue Apr 17 21:19:03 CDT 2012


Why not use an Autoexec macro to run the report?

If you must run a form for some other reason (can't see why, but if...) you
could still use a autoexec which calls a function  (RunCode()) which opens
that form acformhidden). But at the end of the day it is a unneeded
intermediary step (and you're left with a hidden form open to no one's
benefit, right?) , so just open the report using the function that the
autoexec calls via runcode.
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Brad Marks
Sent: Tuesday, April 17, 2012 9:45 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] How to Show a Specific Report at Initiation Time(When
there is also a default form)

Joe,

Thanks for the help, I appreciate it.

The situation that I am dealing with is quite simple, but a little
different.

To isolate the problem, I set up a small Access application that has only
one form and one report.  The form is not a popup form.

The form is designated as the default "Display" form that is automatically
opened at startup time.

The form opens the report on the form's "On Load" event (This works nicely)

I then tried to make the form not visible via the Report's Load Event (I
tried the Report's Open event also)

For some reason the code "Forms.form1.Visible = False" does not work.

I must be missing something.

Thanks,

Brad


 

  

-----Original Message-----
From: accessd-bounces at databaseadvisors.com on behalf of Joe O'Connell
Sent: Tue 4/17/2012 7:39 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] How to Show a Specific Report at Initiation
Time(Whenthere is also a default form)
 
Brad,

It sounds like you have a popup form that opens a report, so the report
"sits behind" the form.  If there is only 1 form and 1 report, then when
the report opens have it hide the form and then unhide it when the
report is closed.  However sometimes there can be multiple forms open
that could open multiple reports in any sequence, then you need a more
generic solution to hide all popup forms when the first report opens and
to unhide all forms when the last report closes.  Here are 2 subroutines
that are easily invoked to hide and unhide all popup forms.

Put this in a new module:

Option Compare Database
Option Explicit
    Dim i As Integer, intNum As Integer, intNumOpenReport As Integer
    Dim strPopupForm() As String
    Const conObjStateClosed = 0

Public Sub HidePopupForms()
    On Error Resume Next
    If intNumOpenReport = 0 Then
        intNum = 0
        For i = 0 To Forms.Count - 1
            If Forms(i).PopUp = True And Forms(i).Visible = True Then
                Forms(i).Visible = False
                intNum = intNum + 1
                ReDim Preserve strPopupForm(intNum)
                strPopupForm(intNum) = Forms(i).name
            End If
        Next i
    End If
    intNumOpenReport = intNumOpenReport + 1
End Sub

Public Sub RestorePopupForms()
    On Error Resume Next
    If intNumOpenReport = 1 Then
        For i = 1 To intNum
            Forms(strPopupForm(i)).Visible = True
        Next i
        ReDim strPopupForm(0)
        End If
    intNumOpenReport = intNumOpenReport - 1
End Sub

In the open procedure for each report Call HidePopupForms() and in the
close procedure for ach report Call RestorePopupForms()

Joe O'Connell

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Brad Marks
Sent: Tuesday, April 17, 2012 7:59 AM
To: Access Developers discussion and problem solving
Subject: [AccessD] How to Show a Specific Report at Initiation Time
(Whenthere is also a default form)

All,

We have an Access 2007 application that is used  by a number of people.

The form that is automatically opened for this ap is a type of report
menu.

Recently a key player has asked that when the application is opened, he
would like to see one report automatically shown on the screen (without
needing to push any button or select any tab).

Is there a way to have a default form, and yet open a report and give it
the focus.

I know how to discern the user-id, that it not a problem.

The problem is that if I open up the report on the Form Load Event, the
report is opened, but only a tab is shown for the report, and the report
itself is not visible as it is covered by the default form.

I thought that this would be easy to do .  I must be missing something.

Thanks,
Brad

     



-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.




More information about the AccessD mailing list