R Tanner said:
Hi,
I have an application where a user must sign in before continuing.
Would it be better to assign the user's sign in status to a public
variable or a global constant or are these virtually the same...
A constant ("Const x") is a constant, and its value can't be changed at run
time. So you can't use a constant for what you are doing. A Public
variable in a standard module is the same as a Global variable, and is
probably what you want. However, be aware that an unhandled error will rest
all variables, and so you must implement error-handling in your code to
ensure that there are no unhandled errors, if you want to be sure that the
user's sign-in status is not lost.
That may not be a problem, if all you need to do is ask the user to sign in
again in the (hopefully) rare event of an unhandled error. Alternatives to
public variables are (a) saving the value in a text box on a hidden form,
and (b) saving the status in a local table. Each has its drawbacks, of
course, though having a hidden form is convenient for lots of things.