Thursday, May 5, 2011

Global variables in Access database

The only persistent data in our application is the data in the database. Until now the only dialog data has been some data in the forms, for instance the value of the unbound controls. This data disappears when the form closes, so we need some way to handle dialog data that lives across the entire dialog with the user. Modules is the solution to the problem because a module is open and holds data as long as the application is running. As a simple example, we will see how to handle a simulated today's date. In the real system, we need to show today's date in many places, for instance as the default search criterion for arrival date.It is easy to do by means of the built-in function Date( ) which always gives us today's date (or rather the current date setting in the computer).

However, when testing the system, our test data is planned for some specific dates. We cannot change the test data every day we need it. We might instead change the current date setting of the system to the simulated date, but this is not recommended because it has side effects on other things, for instance the date of files created or changed, which again may create havoc in automatic backup procedures.











In this Example, Date is a global variable, sim Date is Access Function.

No comments: