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  

Report will not access public variables from form



 
 
Thread Tools Display Modes
  #1  
Old May 4th, 2005, 08:58 PM
Lee
external usenet poster
 
Posts: n/a
Default Report will not access public variables from form

On a form, I have declared public variables for current (old) values in the
controls and also edited (new) values. There are manipulated through code
behind the form correctly.
After a save record on the form, I send a report by email that tells the
client that revisions to the record on the form have changed.
In OnOpen event on the report I have some if statements to print the old and
new values on the report if they differ, e.g.(or i.e.)
If gstrPARTNoOld gstrPARTNoNew Then
Me.txtPartNoNew = gstrPARTNoNew
Me.txtPartNoOld = gstrPARTNoOld
End If
I have stepped through the code and the values for the public variables are
not shuffling from the form over to the report. The form is still open
although it has lost focus as the report is in preview mode. What am I
forgetting to do?
--
Lee
Redmond, Wasington
  #2  
Old May 4th, 2005, 09:26 PM
Ofer
external usenet poster
 
Posts: n/a
Default

When you declare global variable in your form you can use them every where in
that form but not outside the form, if you want to use the variable every
where then declare them in a module and not in your form.
and dont forget to remove them from your form.

"Lee" wrote:

On a form, I have declared public variables for current (old) values in the
controls and also edited (new) values. There are manipulated through code
behind the form correctly.
After a save record on the form, I send a report by email that tells the
client that revisions to the record on the form have changed.
In OnOpen event on the report I have some if statements to print the old and
new values on the report if they differ, e.g.(or i.e.)
If gstrPARTNoOld gstrPARTNoNew Then
Me.txtPartNoNew = gstrPARTNoNew
Me.txtPartNoOld = gstrPARTNoOld
End If
I have stepped through the code and the values for the public variables are
not shuffling from the form over to the report. The form is still open
although it has lost focus as the report is in preview mode. What am I
forgetting to do?
--
Lee
Redmond, Wasington

  #3  
Old May 4th, 2005, 09:37 PM
Lee
external usenet poster
 
Posts: n/a
Default

Sorry for being too brief.
The public variables are in the declarations section of the form's module so
they should be available outside the form.

Also, using Access 2000

--
Lee
Redmond, Wasington


"Ofer" wrote:

When you declare global variable in your form you can use them every where in
that form but not outside the form, if you want to use the variable every
where then declare them in a module and not in your form.
and dont forget to remove them from your form.

"Lee" wrote:

On a form, I have declared public variables for current (old) values in the
controls and also edited (new) values. There are manipulated through code
behind the form correctly.
After a save record on the form, I send a report by email that tells the
client that revisions to the record on the form have changed.
In OnOpen event on the report I have some if statements to print the old and
new values on the report if they differ, e.g.(or i.e.)
If gstrPARTNoOld gstrPARTNoNew Then
Me.txtPartNoNew = gstrPARTNoNew
Me.txtPartNoOld = gstrPARTNoOld
End If
I have stepped through the code and the values for the public variables are
not shuffling from the form over to the report. The form is still open
although it has lost focus as the report is in preview mode. What am I
forgetting to do?
--
Lee
Redmond, Wasington

  #4  
Old May 5th, 2005, 12:03 AM
Marshall Barton
external usenet poster
 
Posts: n/a
Default

Lee wrote:

Sorry for being too brief.
The public variables are in the declarations section of the form's module so
they should be available outside the form.

Also, using Access 2000



Well, they are, but it's different than public variables in
a standard module.

A form/report's module is a Class Module where module level
Public variables are properties of the class (and Public
Subs/Functions are methods). This means that the syntax to
refer to the variables is:

Forms!formname.variablename

--
Marsh
MVP [MS Access]
  #5  
Old May 5th, 2005, 04:51 PM
Klatuu
external usenet poster
 
Posts: n/a
Default

Public Variables - Bad

Always avoid public varialbes. In your report, you can reference values in
your form. For example if you need to use the value of TextBox1 from your
form in the report, reference it as forms!MyForm!TextBox1

"Lee" wrote:

Sorry for being too brief.
The public variables are in the declarations section of the form's module so
they should be available outside the form.

Also, using Access 2000

--
Lee
Redmond, Wasington


"Ofer" wrote:

When you declare global variable in your form you can use them every where in
that form but not outside the form, if you want to use the variable every
where then declare them in a module and not in your form.
and dont forget to remove them from your form.

"Lee" wrote:

On a form, I have declared public variables for current (old) values in the
controls and also edited (new) values. There are manipulated through code
behind the form correctly.
After a save record on the form, I send a report by email that tells the
client that revisions to the record on the form have changed.
In OnOpen event on the report I have some if statements to print the old and
new values on the report if they differ, e.g.(or i.e.)
If gstrPARTNoOld gstrPARTNoNew Then
Me.txtPartNoNew = gstrPARTNoNew
Me.txtPartNoOld = gstrPARTNoOld
End If
I have stepped through the code and the values for the public variables are
not shuffling from the form over to the report. The form is still open
although it has lost focus as the report is in preview mode. What am I
forgetting to do?
--
Lee
Redmond, Wasington

 




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
Is it possible to show both "Yes" and "No" answers from a "yes/no" checkbox? Colin Foster New Users 28 March 18th, 2005 02:19 PM
Total hours from Table into Report HeatherLou1974 General Discussion 3 March 7th, 2005 08:04 PM
Dates in a listbox connected to a form... RusCat Using Forms 13 November 25th, 2004 02:31 AM
6 Tables, 1 Report, W/O 6 Qrys Andy Setting Up & Running Reports 9 June 29th, 2004 09:52 PM
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 03:19 AM.


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