Re: Display a public variable value in a text box....
- From: Nikos Yannacopoulos <nyannacoREMOVETHISBIT@xxxxx>
- Date: Fri, 03 Jun 2005 10:00:55 +0300
Klatuu,
This sounds very interesting, and I would certainly like to have a look at it (at your convenience) if you don't mind!
Regards, Nikos
Klatuu wrote:
Nikos,
I support your position on Public variables. There is another way to accomplish this that is more native to Access and avoids having to keep track of it at all. That is to create an application level property to hold the user name and load the value after the user has logged in. that way, it is always accessable. I use this in an application I have where the client wanted a security module other than Access. It creates two properties, UserName, and UserLevel, so I know what the user is allowed to do. Unfortunately, I don't have the code with me. It is at home. If you need it, post back and I can bring it in tomorrow.
"Nikos Yannacopoulos" wrote:
Gaba,
Public variables can only be referenced in code. To retrieve a public variable's value in a form, report, query etc you need to write a function to return its value, and call that from your form etc. For instance, assuming your public variable is called MyVariable, write a function in a general module like:
Function GetMyVariable() GetMyVariable = MyVariable End Function
Then you can call the function from anywhere in your project. So, to display its value in a textbox on a form, you would put this in the textbox's control source:
=GetMyVariable()
That said, that's all theory, but it's not good practice, simply because public variables are reset as soon as an untrapped error occurs in your code. Therefore it is safer to use controls on forms to store values, which do not suffer from this problem. In your particular case, you would go the other way around, i.e. once the user provides their username you store it directly in the textbox (or label) on the form (which, I undertand, remains open at all times anyway), and read it from there whenever required.
Generally, one can use hidden controls on a form to store values so they are not seen, or, in the absense of a switchboard or other form that remains open at all times, one can make a form just for the purpose, open it at startup and keep it open but hidden as long as the database is open.
HTH, Nikos
gaba wrote:
Hello,
I'm working with a login form (it saves the username in a public variable after verifying password), after that the form is closed. I'm trying to display the public variable in a text box on the main menu, so when is always displaying which user had login...
Any ideas? any help will be greatly appreciated
gaba :)
.
- Follow-Ups:
- Re: Display a public variable value in a text box....
- From: Klatuu
- Re: Display a public variable value in a text box....
- From: Klatuu
- Re: Display a public variable value in a text box....
- References:
- Display a public variable value in a text box....
- From: gaba
- Re: Display a public variable value in a text box....
- From: Nikos Yannacopoulos
- Re: Display a public variable value in a text box....
- From: Klatuu
- Display a public variable value in a text box....
- Prev by Date: Re: User Name
- Next by Date: Re: Display memo field depending on combo box choice (?)
- Previous by thread: Re: Display a public variable value in a text box....
- Next by thread: Re: Display a public variable value in a text box....
- Index(es):
Relevant Pages
|
Loading