Go to: Articles List

Application Object Explained

The Application object is used to share information with all users of your application. When you set an Application Variable, that same variable is accessible throughout your application. An example of this would be to set an Application Variable for your database connection string:

Application("ConnStr") = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=G:\path\yourdb.mdb;"

The above code sets an Application Variable named "ConnStr" equal to the database connection string. It can then be accessed like this:

myDBConnStr = Application("ConnStr")

The above code sets a variable "myDBConnStr" equal to the Application Variable "ConnStr". It can then be used to connect to the database.

Similar to the above use you can use Application Variables to keep track of various commonly used information (paths, common urls, etc).

There are two methods that will help you use Application Variables:

Application.Lock - Prevents more than one user at a time from modifying a particular variable.
Application.UnLock - Unlocks the variables so that they can be used by another user.

An example of this would be if you had a statement that was going to be modified regularly and you wanted to keep track of the date and time that it was modified. After each time that it was changed you could set an Application Variable:

Application.Lock
Application("ModifiedDate") = Now
Application.UnLock