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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|
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 |