Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

setting variables 1

Status
Not open for further replies.

primerov

Technical User
Aug 16, 2002
160
0
0
BG


Setting variables


In my modules made public, i have several functions where i must set the variables each time
for each function.
For example :



Set chickens = [Forms]![Farm]![Subform].[Form].[Quantity]
Set poultry = [Forms]![Farm]![Subform].[Form].[cartons]
Set customer = main![Customerid]
etc
etc



Since i have more variables to set, i would like to ask is there any way
to put these setting in the general section of the code and to be made public to
all the functions in the database?
 
If you HAVE too, you could declare them as public in a general module, then set their values in the after update event of the text boxes.

So create module PublicVars, and declare:

Public numChickens As Long
Public numPoultry As Long

Then, in the after update event of any text boxes that you need to change the value:

numChickens = Me.Quantity

or

numChickens = numChickens + Me.Quantity



-Gary
 
primerov

Gary said:
If you HAVE too

Using a lot of global variables may be a tad dangerous. I do not know the reasoning or your design, but if you have to reference values in a form perhaps you may consider an alternate approach. Perhaps a multitab form with the "global" settings in the header of the form. Each tab and each subform can reference the variable in the header part of the form.

Richard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top