Log name of user of database...

dat_geezer

Registered User.
Local time
Today, 11:32
Joined
Mar 21, 2007
Messages
10
Hi guys, i have a question and wanted to see if anyone knows how to do it. Ok, i have a order system, and it works fine. But i also have a login prompt, which also works, which i then linked to the splash screen of the system, which displays a greeting message. But what i want to know is, is it possible to log the name of the user you have logged in as in your database. Currently i have the name set as the name on MY computer, eg...my login name is John, but my database record is Bill...i want Bill to be on the greeting instead of John, to create the scenario where i am part of the staff logging into the system. Any help would be greatful, cheers.
 
Hi guys, i have a question and wanted to see if anyone knows how to do it. Ok, i have a order system, and it works fine. But i also have a login prompt, which also works, which i then linked to the splash screen of the system, which displays a greeting message. But what i want to know is, is it possible to log the name of the user you have logged in as in your database. Currently i have the name set as the name on MY computer, eg...my login name is John, but my database record is Bill...i want Bill to be on the greeting instead of John, to create the scenario where i am part of the staff logging into the system. Any help would be greatful, cheers.

I think the easiest way would be to create a Global (public) variable called something like CurrentUser. When you log in, it would assign the current user variable name to the login name, then you could use that on the SplashScreen. You could also use it to create a log of who was on the computer, and when using the same variable. Myself and Chan210 did something very similar to this a few weeks ago with his program.
 
a global variable? would that go in vb code or the properties :S im not sure where u are coming from.
im still quite a novice at access tbh. wot i am doing is for a project. although i have fulfilled my project criteria, i just want to see how far i can go with it as i still have a month left to work on it. =)
i can create a log of who has used the computer, but what i really want is for the name i have entered in the login form, to show on the splash screen as a greeting, but currently it is showing my real login =P
 
a global variable? would that go in vb code or the properties :S im not sure where u are coming from.
im still quite a novice at access tbh. wot i am doing is for a project. although i have fulfilled my project criteria, i just want to see how far i can go with it as i still have a month left to work on it. =)
i can create a log of who has used the computer, but what i really want is for the name i have entered in the login form, to show on the splash screen as a greeting, but currently it is showing my real login =P

Go to the database window, choose Modules, then New. In the open window type

Public CurrentUser As String

Then save the module with a name of your choosing. What you have done is created a global or Public Variable.

Then in the login form use the login to capture that name with a textbox using something like:

CurrentUser = Me.txtCurrentUser

That will set the variable to the name you typed in. From then on you can refer to CurrentUser in any form and it will remember that it equals the name you typed in. So in the splashscreen you can do something like ...

"Welcome " & [CurrentUser]
 
i understand how this would work, but my list of usernames is in a lookup, so how would i go about adding the rule:

currentuser = me.txtcurrentuser

as everytime i do it, i cant go any further.
 
i understand how this would work, but my list of usernames is in a lookup, so how would i go about adding the rule:

currentuser = me.txtcurrentuser

as everytime i do it, i cant go any further.

Well, for the simple purpose of echoing a name to a SplashScreen, you wouldn't even need the lookup if the purpose of the login was not for security, but just to get the name for the SplashScreen. But, if you wanted to control the level of access or track the login user, then it would be more complicated. Personally, I try not to use lookups ... and this illustrates one reason why. I would use a separate security table that contained the user name, password, and access level - and draw my data from there. But with that said, you could write a bit of code to match the login name (network or standalone computer login) with the lookup - then assign that to the global variable on the OnClick event for the login. The key is to pass the Public Variable the correct data so it can be used later on.

If you have the time, upload a stripped down version of the db and let's have a look at it. I'm sure there's a way to get this done without too much pain :)
 
well thats what i did, i have a table with username and password then linked the lookup to the table using code. =)
i tried your method by adding the public varialbe to the onclick but when i try to change user i get the error:
compile error:

invaid attribute in sub or function

i will upload a copy of my database if you want haha. its not very good though =)
 
well thats what i did, i have a table with username and password then linked the lookup to the table using code. =)
i tried your method by adding the public varialbe to the onclick but when i try to change user i get the error:
compile error:

invaid attribute in sub or function

i will upload a copy of my database if you want haha. its not very good though =)

Please do. There's probably something in it that we're not seeing here.
 
Don't worry about that; but you never know, we might be able to give you some other pointers while trying to solve this issue for you.

I agree. I did a quick login form for another program that I have and used the Public variable pCurrentUser to assign the login name on the Oncurrent event for another form (me.text86=pCurrentUser) - and no problems. So I think it's probably something simple.
 
this is gonna sound really dumb....but how would i strip down my database? :S ive never done it before haha...
 
this is gonna sound really dumb....but how would i strip down my database? :S ive never done it before haha...

Take out all personal information, remove data from tables (just leave enough for it to work) then do a compact and repair. (TOOLS/ DATABASE UTILITIES/COMPACT and REPAIR DATABASE) Once you have done that, zip the db. It must be less than 393KB when zipped. If it is still too large, remove some of the forms that don't effect it's operation when showing the problem - and try again.

Then upload it here using the manage attachments option when you reply.
 
hmm i cant seem to get the file size to be lower than 15mb??
i have stripped it down and comact and repair but its still 15...
there is only two forms and one table and there isnt much information in there, just enough to do that login thing. =S
 
Are you using embedded pictures on the form(s)? That will cause the db to be that big with it compacted. Plus, after you compact and repair, you still have to Zip it up into a zip file.
 
no i only have a picture on the background of the form. would this affect the filesize? cant access zip program as im in university right now, but i will try when i get back home.
 
managed to remove the background pic and the filesize did decrease greatly. anyway, here's the database...i kept as much info as i could on, as its not important to me particularly whats on it! aslong as it works =)

anywayz, i have uploaded it!
 

Attachments

Can you reiterate what isn't working for you? I'm not sure, just by looking at it, what part isn't working the way you want it to.
 
well i have the staff usernames..and what i want is for their names to show up when they login. But instead, i only get the username of the user on their CURRENT system, which i dont want as the system im on isnt part of the order system. If you want to try the login the password is just their names.
 
Okay, here goes:

1. Rename your module basCurrentUser as you can't have the module name the same name as the variable.

2. In the Click event of the button on your login form add the part in red:
Code:
    'Check value of password in tblEmployees to see if this
    'matches value chosen in combo box

    If Me.Text6.Value = DLookup("Password", "Staff", _
                                      "[Staff ID]=" & Me.Combo2.Value) Then

        staffID = Me.Combo2.Value
[B][COLOR="Red"]        CurrentUser = DLookup("[First Name]", "Staff", "[Staff ID]=" & Me.Combo2)
        CurrentUser = CurrentUser & " " & DLookup("[Surname]", "Staff", "[Staff ID]=" & Me.Combo2)[/COLOR][/B]        'Close logon form and open splash screen

        DoCmd.Close acForm, "LoginForm", acSaveNo
        DoCmd.OpenForm "Splash"

    Else
        MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
        Me.Text6.SetFocus
    End If


3. Add this to the On Load event of your Splash (which isn't really a splash form - a splash is something that comes up and shows a logo, or information about the program, and then goes away):
Code:
    Me.Text13 = CurrentUser
 

Users who are viewing this thread

Back
Top Bottom