Username Help

jeffrey159

Registered User.
Local time
Today, 00:39
Joined
Jan 17, 2013
Messages
24
Sorry if the title is misleading or wrong. i got no idea what to search on google

i need to code a form which in Login(completed) i enter user and pass and enter, it takes me to another form LoginMenu and in that form i want it to show Welcome, "username" after pressing login via Login

how do i code it??

Question 2:
how do i query a set of unbound items to a listbox

i915.photobucket.com/albums/ac355/jeffrey159/Untitled_zpsac119d98.jpg

after selecting the ticket type and entering quantity and press the "sell" button
how does it enter into the Ticket List box??
what's the code to enter it???:(
 
There are several ways of handling this. Assuming that there is no actual security system, you could simply hide the login form and bind the label of the next form that opens to the control on the login form.

If you want to use the Windows login account, then you would make a call to the Windows API and pull the Windows login account from the environmental variables.

Code:
Dim user_id As String
 
user_id = Environ("UserName")

If you built a security module, you could create a global variable and populate it with the login name, then call that global variable when defining the caption property of the label control on subsequent forms.

I could go on, but I think you get the idea.
 
Last edited:
For Question #2, you would dynamically build the SQL that defines the rowsource/recordsource property of the listbox. To do this you build the SELECT statement in code using values drawn from your unbound controls on the form to populate the WHERE clause of the SQL statement. I like to store the dynamic SQL statement in a string variable, then set recordsource/rowsource property of the listbox control to be equal to the string variable at run-time. You would then requery the listbox to make sure that the values displayed represent updated results.

The value set approach to solving this problem would be to hard code the values you want and repopulate the list box using something like a case selection statement where each case represents the values you have to choose from in the unbound (combobox or listbox) field that sets criteria for the next combobox/listbox. Syntax for defining the values to appear in the listbox using for this approach is exactly the same as if you were to define the listbox value list at design time using the properties box.
 
... because they are very easily changed
Not really all that easy and it really depends on how secure your database needs to be. I'd argue that if it needs to be secure enough to not allow the environment variable to be changed, then it shouldn't be in Access in the first place.
 
Not really all that easy

Really? Run this command:
Set username=AnythingYouLike

Or go to Advanced System Settings in System Properties and add username as a new environment variable.

Why would anyone use the environment variable when the actual username can be returned with one line?
 
Really? Run this command:
Set username=AnythingYouLike

Or go to Advanced System Settings in System Properties and add username as a new environment variable.

Why would anyone use the environment variable when the actual username can be returned with one line?
Umm, I've actually tried that and it does not work like you say. Now, if you do it from code within a certain instance of Access, it will work but it will not work the next time you open it and, you must be able to get to the VBA window to do so.

Too much paranoia over the remoteness of this. And there is absolutely no reason Access should be storing your data if it has to be that secure. Simple. So, why use it? Because it works for many, many purposes without having to do more.
 
Umm, I've actually tried that and it does not work like you say.

Code:
Set username=WhateverYouWant

In a cmd window or the Run box. It is the DOS Set command not the VBA Set keyword.

So, why use it? Because it works for many, many purposes without having to do more.

Code:
Environ("username")

versus

Code:
CreateObject("wscript.network").username

OK it is 20 characters longer. If you care about that then just keep using the environment variable. I just thought we were trying to promote best practice?
 
There are several ways of handling this. Assuming that there is no actual security system, you could simply hide the login form and bind the label of the next form that opens to the control on the login form.

If you want to use the Windows login account, then you would make a call to the Windows API and pull the Windows login account from the environmental variables.

Code:
Dim user_id As String
 
user_id = Environ("UserName")
If you built a security module, you could create a global variable and populate it with the login name, then call that global variable when defining the caption property of the label control on subsequent forms.

I could go on, but I think you get the idea.

the problem is that i don't want to use Environ, because i have different set of username to use and not windows login name.

and i don't know what to type in the module to code the username to appear in another form after logging in via the Login Form

can anyone give me example of codes to enter/create in the modules???:o:confused:
 

Users who are viewing this thread

Back
Top Bottom