PC Review


Reply
Thread Tools Rate Thread

Calling a form on report close action.

 
 
NEMO2K
Guest
Posts: n/a
 
      4th Oct 2004
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.
 
Reply With Quote
 
 
 
 
Allen Browne
Guest
Posts: n/a
 
      4th Oct 2004
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" <(E-Mail Removed)> wrote in message
news:2a6e01c4aa18$3daa6250$(E-Mail Removed)...
> 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.



 
Reply With Quote
 
NEMO2K
Guest
Posts: n/a
 
      4th Oct 2004
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" <(E-Mail Removed)> wrote in

message
>news:2a6e01c4aa18$3daa6250$(E-Mail Removed)...
>> 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.

>
>
>.
>

 
Reply With Quote
 
Allen Browne
Guest
Posts: n/a
 
      4th Oct 2004
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" <(E-Mail Removed)> wrote in message
news:2afb01c4aa1e$16d19030$(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in

> message
>>news:2a6e01c4aa18$3daa6250$(E-Mail Removed)...
>>> 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.



 
Reply With Quote
 
NEMO2K
Guest
Posts: n/a
 
      5th Oct 2004
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" <(E-Mail Removed)> wrote in

message
>news:2afb01c4aa1e$16d19030$(E-Mail Removed)...
>> 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" <(E-Mail Removed)> wrote in

>> message
>>>news:2a6e01c4aa18$3daa6250$(E-Mail Removed)...
>>>> 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.

>
>
>.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Close button on a form will not close form - error 2585 - action cannot be carried out while processing a form Angus Comber Microsoft Access 2 19th Jul 2006 12:21 PM
Close form if no user action including mouse move over form. =?Utf-8?B?Um9i?= Microsoft VB .NET 6 7th Jun 2006 11:20 AM
Close report action based on criteria =?Utf-8?B?Qi4gTWVpbmNrZQ==?= Microsoft Access Reports 2 5th Aug 2005 01:38 AM
how to cancel 'close form' action? Alex Microsoft Access Forms 1 9th May 2004 06:44 AM
Close Form after custom Action Kai Schlotmann Microsoft Outlook Form Programming 1 11th Dec 2003 02:46 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:16 PM.