PC Review
Forums
Newsgroups
Microsoft Access
Microsoft Access VBA Modules
Calling Form from Report
Forums
Newsgroups
Microsoft Access
Microsoft Access VBA Modules
Calling Form from Report
![]() |
Calling Form from Report |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
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? |
|
|
|
#2 |
|
Guest
Posts: n/a
|
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] |
|
|
|
#3 |
|
Guest
Posts: n/a
|
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] > |
|
|
|
#4 |
|
Guest
Posts: n/a
|
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() |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

