Heenan, Lambert
Lambert.Heenan at AIG.com
Thu Aug 7 11:21:13 CDT 2003
One important distinction to note about code modules behind forms and reports is that these modules are Class modules, not "Standard" modules. So any "public" variables declared in them can only be accessed using Object.Variable notation. Whereas if you declare a public variable in a standard module you can simply refer to it by name anywhere else in the project. The reason for the difference is that public variables in a form module are actually members of the form's class, not stand alone variables. As yet another wrinkle to be aware of, you cannot directly reference anything in a form, instead you have to do it via the Forms collection: which is a collection of all OPEN forms. So to do what you want the syntax would be... Me.hours111 = Forms("frmpayroll").f_shift_hours3 + Forms("frmpayroll").f_shift_hours2 + Forms("frmpayroll").f_shift_hours1 HTH Lambert > -----Original Message----- > From: Julie Reardon-Taylor [SMTP:prosoft6 at hotmail.com] > Sent: Thursday, August 07, 2003 12:01 PM > To: accessd at databaseadvisors.com > Subject: [AccessD] Public Variables in a Report > > Okay, Gustav gave me some information about using public variables, and > said > that I have to move my variables from the code behind the form to a module > > in order to be able to see the value of those variables in a report. > > However, I found, in an Access 2000 programming book, that I supposedly > can > use the public variable anywhere within the project if I reference the > form > first and then the variable name. > > Anyone have experience doing this? Here is an example: > > Me.hours111 = frmpayroll.f_shift_hours3 + frmpayroll.f_shift_hours2 + > frmpayroll.f_shift_hours1 > > The Me.hours111 references the unbound text box on my report. The other > items that I am trying to add are declared as public variables in the > general section of the code behind the form named frmPayroll. Access > tells > me that it cannot find the variable. > > Help! > > > > Julie Reardon-Taylor > PRO-SOFT OF NY, INC. > www.pro-soft.net > > _________________________________________________________________ > Help STOP SPAM with the new MSN 8 and get 2 months FREE* > http://join.msn.com/?page=features/junkmail > > _______________________________________________ > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com