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.
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" <anon...@discussions.microsoft.com> wrote in message
news:2a6e01c4aa18$3daa6250$a301...@phx.gbl...
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
>.
>
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" <anon...@discussions.microsoft.com> wrote in message
news:2afb01c4aa1e$16d19030$a301...@phx.gbl...
> 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.
>>
>>
it works! Believe me when I say thank you very much.
Greetings,
NEMO2K
>.
>