A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Setting Up & Running Reports
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Calling a form on report close action.



 
 
Thread Tools Display Modes
  #1  
Old October 4th, 2004, 02:44 PM
NEMO2K
external usenet poster
 
Posts: n/a
Default Calling a form on report close action.

Hi All,

if there's somebody out there who can help me in solving
the following problem, I'd be very grateful.
I need to open a report from several forms and, once the
report is closed to go back to the calling form. The form
must not be closed when report opens (only minimize or not
visible). I tryed to pass to an hidden control in the
report the Screen.ActiveForms.Name property but I get
always an error from the system which doesn't let me pass
this value to the opening report. If I could store this
value in a variable I could call it on report close action.
I would greatly appreciated any suggestion.
Thanks,

NEMO2K.
  #2  
Old October 4th, 2004, 02:57 PM
Allen Browne
external usenet poster
 
Posts: n/a
Default

The simplest thing to do would be to leave the form open behind the report.
When you close the report, voila: there is your form.

If you are using Access 2002 or later, you could pass the name of the form
in the OpenArgs of OpenReport. Then in Report_Close you can show the form
with:
Forms(Me.OpenArgs).SetFocus
In earlier versions you could use a public string variable to store the name
of the form, read that into a variable in Report_Open, and then use the
variable in Report_Close.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"NEMO2K" wrote in message
...
Hi All,

if there's somebody out there who can help me in solving
the following problem, I'd be very grateful.
I need to open a report from several forms and, once the
report is closed to go back to the calling form. The form
must not be closed when report opens (only minimize or not
visible). I tryed to pass to an hidden control in the
report the Screen.ActiveForms.Name property but I get
always an error from the system which doesn't let me pass
this value to the opening report. If I could store this
value in a variable I could call it on report close action.
I would greatly appreciated any suggestion.
Thanks,

NEMO2K.



  #3  
Old October 4th, 2004, 03:26 PM
NEMO2K
external usenet poster
 
Posts: n/a
Default

Hi Allen,

as the calling is a pop-up form, it will be always on top
and I'm compelled to move it manually with mouse if I want
to see the below report preview. I'm using A97 version:
where should I declare the public variable to store the
form name? Are you so kind to explain me the correct
procedure?
Thanks in advance,

NEMO2K
-----Original Message-----
The simplest thing to do would be to leave the form open

behind the report.
When you close the report, voila: there is your form.

If you are using Access 2002 or later, you could pass the

name of the form
in the OpenArgs of OpenReport. Then in Report_Close you

can show the form
with:
Forms(Me.OpenArgs).SetFocus
In earlier versions you could use a public string variable

to store the name
of the form, read that into a variable in Report_Open, and

then use the
variable in Report_Close.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"NEMO2K" wrote in

message
...
Hi All,

if there's somebody out there who can help me in solving
the following problem, I'd be very grateful.
I need to open a report from several forms and, once the
report is closed to go back to the calling form. The

form
must not be closed when report opens (only minimize or

not
visible). I tryed to pass to an hidden control in the
report the Screen.ActiveForms.Name property but I get
always an error from the system which doesn't let me

pass
this value to the opening report. If I could store this
value in a variable I could call it on report close

action.
I would greatly appreciated any suggestion.
Thanks,

NEMO2K.



.

  #4  
Old October 4th, 2004, 03:38 PM
Allen Browne
external usenet poster
 
Posts: n/a
Default

In a standard module (on created through the Modules tab of the Database
window), enter this in the General Declarations section (at the top, with
the Option statements):
Public gstrCallingForm As String

In the code that opens the report:
gstrCallingForm = Me.Name
DoCmd.OpenReport "MyReport", acViewPreview
Me.Visible = False

In the General Declaration section of the report's module:
Dim mstrCallingForm As String

In the Open event procedure of the report:
Private Sub Report_Open(Cancel As Integer)
mstrCallingForm = gstrCallingForm
gstrCallingForm = ""
End Sub

In the Close event procedure of the report:
Private Sub Report_Close()
If Len(mstrCallingForm) 0 Then
If IsLoaded(mstrCallingForm) Then
Forms(mstrCallingForm).SetFocus
End If
End If
End Sub

Copy the IsLoaded() function from the Utility module of the Northwind sample
database.

You might be able to get away without the module level variable in the
report, but that approach will cope with multiple forms and reports opening
and closing at the same time.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"NEMO2K" wrote in message
...
Hi Allen,

as the calling is a pop-up form, it will be always on top
and I'm compelled to move it manually with mouse if I want
to see the below report preview. I'm using A97 version:
where should I declare the public variable to store the
form name? Are you so kind to explain me the correct
procedure?
Thanks in advance,

NEMO2K
-----Original Message-----
The simplest thing to do would be to leave the form open

behind the report.
When you close the report, voila: there is your form.

If you are using Access 2002 or later, you could pass the

name of the form
in the OpenArgs of OpenReport. Then in Report_Close you

can show the form
with:
Forms(Me.OpenArgs).SetFocus
In earlier versions you could use a public string variable

to store the name
of the form, read that into a variable in Report_Open, and

then use the
variable in Report_Close.


"NEMO2K" wrote in

message
...
Hi All,

if there's somebody out there who can help me in solving
the following problem, I'd be very grateful.
I need to open a report from several forms and, once the
report is closed to go back to the calling form. The

form
must not be closed when report opens (only minimize or

not
visible). I tryed to pass to an hidden control in the
report the Screen.ActiveForms.Name property but I get
always an error from the system which doesn't let me

pass
this value to the opening report. If I could store this
value in a variable I could call it on report close

action.
I would greatly appreciated any suggestion.
Thanks,

NEMO2K.



  #5  
Old October 5th, 2004, 08:13 AM
NEMO2K
external usenet poster
 
Posts: n/a
Default

Allen,

it works! Believe me when I say thank you very much.
Greetings,

NEMO2K
-----Original Message-----
In a standard module (on created through the Modules tab

of the Database
window), enter this in the General Declarations section

(at the top, with
the Option statements):
Public gstrCallingForm As String

In the code that opens the report:
gstrCallingForm = Me.Name
DoCmd.OpenReport "MyReport", acViewPreview
Me.Visible = False

In the General Declaration section of the report's module:
Dim mstrCallingForm As String

In the Open event procedure of the report:
Private Sub Report_Open(Cancel As Integer)
mstrCallingForm = gstrCallingForm
gstrCallingForm = ""
End Sub

In the Close event procedure of the report:
Private Sub Report_Close()
If Len(mstrCallingForm) 0 Then
If IsLoaded(mstrCallingForm) Then
Forms(mstrCallingForm).SetFocus
End If
End If
End Sub

Copy the IsLoaded() function from the Utility module of

the Northwind sample
database.

You might be able to get away without the module level

variable in the
report, but that approach will cope with multiple forms

and reports opening
and closing at the same time.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"NEMO2K" wrote in

message
...
Hi Allen,

as the calling is a pop-up form, it will be always on

top
and I'm compelled to move it manually with mouse if I

want
to see the below report preview. I'm using A97 version:
where should I declare the public variable to store the
form name? Are you so kind to explain me the correct
procedure?
Thanks in advance,

NEMO2K
-----Original Message-----
The simplest thing to do would be to leave the form open

behind the report.
When you close the report, voila: there is your form.

If you are using Access 2002 or later, you could pass

the
name of the form
in the OpenArgs of OpenReport. Then in Report_Close you

can show the form
with:
Forms(Me.OpenArgs).SetFocus
In earlier versions you could use a public string

variable
to store the name
of the form, read that into a variable in Report_Open,

and
then use the
variable in Report_Close.


"NEMO2K" wrote in

message
.. .
Hi All,

if there's somebody out there who can help me in

solving
the following problem, I'd be very grateful.
I need to open a report from several forms and, once

the
report is closed to go back to the calling form. The

form
must not be closed when report opens (only minimize or

not
visible). I tryed to pass to an hidden control in the
report the Screen.ActiveForms.Name property but I get
always an error from the system which doesn't let me

pass
this value to the opening report. If I could store

this
value in a variable I could call it on report close

action.
I would greatly appreciated any suggestion.
Thanks,

NEMO2K.



.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Strange stLinkCriteria behaviour on command button Anthony Dowd Using Forms 3 August 21st, 2004 03:01 AM
Save Report With CreateReport Coding Issue Jeff Conrad Setting Up & Running Reports 8 July 12th, 2004 08:39 AM
6 Tables, 1 Report, W/O 6 Qrys Andy Setting Up & Running Reports 9 June 29th, 2004 09:52 PM
How to show image in the form or report? JJ General Discussion 1 June 29th, 2004 06:01 AM
Creating a report from a form Kristin Setting Up & Running Reports 7 June 28th, 2004 09:21 PM


All times are GMT +1. The time now is 04:48 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.