PC Review


Reply
Thread Tools Rate Thread

Calling Form from Report

 
 
=?Utf-8?B?S291IFZhbmc=?=
Guest
Posts: n/a
 
      1st Aug 2007
I am in Report calling a function from another Form. When I call the
function, the value comes into the report as empty? Right before it
finishes, I can clearly see that the value is correct in the code from the
Form, but once it comes back to the code in the Report, it comes in as empty.
Any ideas?

Option Explicit

Dim frm as New [Form_SomeForm]
V as Variant

frm.GetValue
V= GetValue 'GetValue comes in as Empty

Can I not do this from a Reports Code calling a Function from a Form's Code?
 
Reply With Quote
 
 
 
 
Marshall Barton
Guest
Posts: n/a
 
      1st Aug 2007
Kou Vang wrote:

>I am in Report calling a function from another Form. When I call the
>function, the value comes into the report as empty? Right before it
>finishes, I can clearly see that the value is correct in the code from the
>Form, but once it comes back to the code in the Report, it comes in as empty.
> Any ideas?
>
>Option Explicit
>
>Dim frm as New [Form_SomeForm]
>V as Variant
>
>frm.GetValue
>V= GetValue 'GetValue comes in as Empty
>
>Can I not do this from a Reports Code calling a Function from a Form's Code?



You are referring to the wrong instance of the form's class
module. You also must put the executable statements inside
a procedure. For a report, you want it in the format event
of the section that contains the control you want to set.

Unless you have a very good understanding of using multiple
instances of a class object, just refer to the open form:

Option Explicit

Sub Detail_Format( . . .
Dim V as Variant

V= Forms![Form_SomeForm].GetValue()
. . .
End Sub


OTOH, you can avoid all that fooling around if you only want
to display the value in an open form's control. All you
need in this case is for the report text box to use an
expression:
=Forms![Form_SomeForm].GetValue()

--
Marsh
MVP [MS Access]
 
Reply With Quote
 
=?Utf-8?B?S291IFZhbmc=?=
Guest
Posts: n/a
 
      2nd Aug 2007
I am trying to tie everything into the Report_Open sub. I need the value to
calculate a new control source for several txtboxes on the report. The Form
opens the Report which starts the Report _Open Sub, then finishes running on
the Form. I need the Form's data to calculations as well, which some must be
translated to the Report. I have never gone from Form to Report before, and
this is my first time coding to any Sub on a Report. I will try what you
recommended and see what happens. Thanks.

Kou

"Marshall Barton" wrote:

> Kou Vang wrote:
>
> >I am in Report calling a function from another Form. When I call the
> >function, the value comes into the report as empty? Right before it
> >finishes, I can clearly see that the value is correct in the code from the
> >Form, but once it comes back to the code in the Report, it comes in as empty.
> > Any ideas?
> >
> >Option Explicit
> >
> >Dim frm as New [Form_SomeForm]
> >V as Variant
> >
> >frm.GetValue
> >V= GetValue 'GetValue comes in as Empty
> >
> >Can I not do this from a Reports Code calling a Function from a Form's Code?

>
>
> You are referring to the wrong instance of the form's class
> module. You also must put the executable statements inside
> a procedure. For a report, you want it in the format event
> of the section that contains the control you want to set.
>
> Unless you have a very good understanding of using multiple
> instances of a class object, just refer to the open form:
>
> Option Explicit
>
> Sub Detail_Format( . . .
> Dim V as Variant
>
> V= Forms![Form_SomeForm].GetValue()
> . . .
> End Sub
>
>
> OTOH, you can avoid all that fooling around if you only want
> to display the value in an open form's control. All you
> need in this case is for the report text box to use an
> expression:
> =Forms![Form_SomeForm].GetValue()
>
> --
> Marsh
> MVP [MS Access]
>

 
Reply With Quote
 
Marshall Barton
Guest
Posts: n/a
 
      2nd Aug 2007
You can not "push" values into a report. The report shoukd
"pull" values from the form. This is because the report's
Open event is too soon to set the Value property of report
controls. That and the fact that form and report processing
is performed in separate execution tasks that run at
different priorities means that neither one knows what the
other is doing at any point in time. I.e. the form might be
trying to do something to the report before the report is
ready or the report has progressed beyond the point where
the form can affect its behavior.

You said something about "calculate a new control source for
several txtboxes on the report", but that might mean several
different things. However, regardless of its meaning, the
report must do it within its own event procedures.

The report can easily extract information from an open form,
as I said in my first reply, or you might prefer to use the
OpenReport method's OpenArgs argument to pass information
from the form to the report.

I could be more specific if you would provide more
information about what you are trying to accomplish instead
of trying to deal with questions about how you are trying to
accomplish whatever it is you want the report to do.
--
Marsh
MVP [MS Access]


Kou Vang wrote:
>I am trying to tie everything into the Report_Open sub. I need the value to
>calculate a new control source for several txtboxes on the report. The Form
>opens the Report which starts the Report _Open Sub, then finishes running on
>the Form. I need the Form's data to calculations as well, which some must be
>translated to the Report. I have never gone from Form to Report before, and
>this is my first time coding to any Sub on a Report. I will try what you
>recommended and see what happens.
>
>
>> Kou Vang wrote:
>> >I am in Report calling a function from another Form. When I call the
>> >function, the value comes into the report as empty? Right before it
>> >finishes, I can clearly see that the value is correct in the code from the
>> >Form, but once it comes back to the code in the Report, it comes in as empty.
>> > Any ideas?
>> >
>> >Option Explicit
>> >
>> >Dim frm as New [Form_SomeForm]
>> >V as Variant
>> >
>> >frm.GetValue
>> >V= GetValue 'GetValue comes in as Empty
>> >
>> >Can I not do this from a Reports Code calling a Function from a Form's Code?

>>

>
>"Marshall Barton" wrote:
>> You are referring to the wrong instance of the form's class
>> module. You also must put the executable statements inside
>> a procedure. For a report, you want it in the format event
>> of the section that contains the control you want to set.
>>
>> Unless you have a very good understanding of using multiple
>> instances of a class object, just refer to the open form:
>>
>> Option Explicit
>>
>> Sub Detail_Format( . . .
>> Dim V as Variant
>>
>> V= Forms![Form_SomeForm].GetValue()
>> . . .
>> End Sub
>>
>>
>> OTOH, you can avoid all that fooling around if you only want
>> to display the value in an open form's control. All you
>> need in this case is for the report text box to use an
>> expression:
>> =Forms![Form_SomeForm].GetValue()

 
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
Calling report from form that uses Dlookup =?Utf-8?B?TGluZGE=?= Microsoft Access Reports 3 17th May 2007 12:41 AM
Re: Calling a report from popup form =?Utf-8?B?Q2hyaXM=?= Microsoft Access Forms 2 19th Sep 2005 05:40 PM
Calling a form on report close action. NEMO2K Microsoft Access Reports 4 5th Oct 2004 09:13 AM
calling a report from a form Frank Microsoft Access Form Coding 1 3rd Jul 2004 06:14 PM
Calling Filtered report from cmdbutton on form Dale C Gray Microsoft Access Reports 2 24th Sep 2003 02:15 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:22 PM.