Use one of the Events of the Startup Form (e.g. Form_Open or Form_Load
Event, ...) to assign values to the global variables.
However, this is generally a bad idea as global variables are reset to the
default values for their types if there is any untrapped error occurring in
your code. It is much better to store these values in a "Custom Data" Table
(you can assign values to Table Fields on database start-up) and refer to
these Table Field values when you need the value of the "global variables".
These are not affected by untrapped errors.
If you want to use global variables, make sure you use error-trapping
everywhere in your code.
If I understand you correctly I can create a database table and store
variables in them, this will work fine for strings, numbers etc., but what
about object variables. If I for instance would like to refer to some forms
(Form objects) in a global scope, what then?
I don't use Object Variables in global scope since Objects may not exist
(e.g. the Forms are closed) and using the Object Variables in this case will
certainly error out the code.
Generally, I check whether the Object exists and then declare a local-scope
Object Variable which I set to Nothing when the procedure finishes. This
way, I can be sure that I don't leave Objects in the memory.