Log in and Log out information save

Bobby1st

Registered User.
Local time
Today, 16:21
Joined
Jan 5, 2007
Messages
62
User's Log in information save, gone at log out

Hello,

How do we able to save user information at login and have it available at log out (Id and password). I was able to save log-in information but the variable is empty at log out. Can you help?
 
Last edited:
if its empty at logout, you have either

a) not saved it globally
b) overwritten it somewhere
c) had an error that caused the current environment/variables to be "loast"

check your code for instances of the variable, I would think

do you need the login data at logout?
 
Hi gemma-the-husky

Yes, This db tracked user time in and time out. There are a forms, code, module envolved here. Log-in form captures the user ID and password, once identify the switchboard menu opens and user do their thing. On exit is through the switchboard menu and selecting the Exit button. The public variable written on another module comes back empty on the

With rst
.FindLast <<========== will go to error procedure
![PASS] = User2.PASS <<===== empty
.Edit
.!TimeOut = Now()
.Update
End With
 
Last edited:
1) i am not sure exactly which record you will get by using .findlast without setting an index

2) i dont think !pass = user2.pass will do anything without calling .edit FIRST

-------
perhaps you could save the login stuff in the registry

savesetting/getsetting - really easy to use
 
What type of security/log-in model are you using? Is it Access MDW or standard network log-in ID? or some home-grown system you designed with VBA?

If either of the 1st two, then you can grab the userID by calling either of two variables, depending on which system you are using. Otherwise, you will have to keep some form open all the time, or declare/use a global variable in a VBA module. My choice would be to store the variable in the Switchboard form in a public variable, rather than use a globa variable in an outside module. If you ever need to "close" the switchboard, then you can switch the form to visible = false rather than close it out.

Also, I'm not sure if I understand you correctly, but going by how you worded what you said, it appears you are counting on the end-user to close out of the switchboard form and trigger the Exit function to log-out. I would switch the "log-out" tracking function to the On_Close event of the switchboard, so that even if the user clicks the X in the top-right corner of the screen, the tracking function still fires.
 
Your response gave me some ideas, keep the switchboard menu form open by visible = false. Store the variable on the switchboard menue form and use the On_Close event. I am using MSAccess.

I stored the this on a module, maybe move it on the Log-on form code:
Public Type UserInfo
ID As Integer
PASS As String
End Type

Public User2 As UserInfo
==================================Some Log-on form vba codes

ID = UserID.Value <from log-on textbox >
Set db = CurrentDb
‘[ TblAdminCurrMnth contains ID, PASS, Level (access level) fields ]
Set rst = db.OpenRecordset("SELECT * FROM [tblAdminCurrMnth] WHERE [ID]= " & ID)

PASS4 = rst(1).Value
Level = rst(2).Value
Followed by security validation - here, then

With User2 <== this is working
.ID = UserID.Value
.PASS = PASS4
End With
=====================
When the Switchboard menu Exit button is selected, this is the codes that I am having problems to work:
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tblUserLog", dbOpenDynaset)
'<fields: ID, Pass, TimeIn, TimeOut>

With rst
.FindLast <============= Going to error handling
![PASS] = User2.PASS <===== variable is empty ""
.Edit
!TimeOut = Now()
.Update
End With
===================================
I hope I could have illustrate it more clearly this way.
 
Last edited:
I keep wondering why you are storing the password in the log-in/out tracking, but be that as it may. Try placing a breakpoint in your code (on the last line, End With)

Code:
With User2 <== this is working
.ID = UserID.Value
.PASS = PASS4
End With

and tthen see if PASS4 is filling the Users.PASS variable

If it is filling that variable, then you have some problem somewhere else where User2.PASS is either getting filled (with nothing) or destroyed.
 
With User2 <== this is working
.ID = UserID.Value
.PASS = PASS4
End With

Yes, the PASS4.value is pass to rst.PASS and it works. I check the table Userlog and it records the Id, date, and time. I was in the impression that after the information was pass through above Public Type declaration, the information will be keep in memory even after the Log-on form has been close and can be retrieved back on exit. That is not the case as I shown on my codes below but I tried different ways and didn't work.

With rst <=== made a stop here and thereafter, goes to the error handling
.FindLast <============= Going to error handling
![PASS] = User2.PASS <=== while on stop, variable is empty ""
.Edit
!TimeOut = Now()
.Update
End With

You want to know why it's necessary? Maybe not much but we are in a production environment and each employee have a scorecard except for some support staff like this database data entry keyers. We want to have something to measurement performance in the like of volume, time, uph and time on task measurements.

Thanks
 
With User2 <== this is working
.ID = UserID.Value
.PASS = PASS4
End With

Yes, the PASS4.value is transferred to "PASS" and it works. I check the table Userlog and it records the Id, date, and time. I was in the impression that after the information was pass through above Public Type declaration, the information will be keep in memory even after the Log-on form has been close and can be retrieved back on exit. That is not the case as I shown on my codes below but I tried different ways and can't make it to work.

With rst <=== made a stop here and thereafter, goes to the error handling
.FindLast <============= Going to error handling
![PASS] = User2.PASS <=== while on stop, variable is empty ""
.Edit
!TimeOut = Now()
.Update
End With

Is the exit log out information necessary? Maybe not much but we are in a production environment and each employee have a scorecard except for some support staff like this database data entry keyers. We want to have something to measurement performance in the like of volume, time, uph and time on task measurements.

Thanks
 
you mention having tried different ways to reference the User2 variable when the form is closed - which is why I recommended hiding the form. When you close out of the form, any variables declared in that form (even if they are public) won't be available. The only way is to either keep the form open (using hidden method) or move the variable, which unless you are using other variables "globally" you probably won't want to do.

As for my asking "why" I was only referring to storing the password specifically, in the tracking function. I can understand storing the username and log-in/out timestamps, but I can't imagine any reason to store the password in the tracking function.
 
It able to hold and retrieved information from memory, I followed your suggestion to: me.form.visible = false (frmLogon form). In this case, I could have reference the data directly from the password textbox on the frmLogon form, so that's makes my Public User-type declaration on the module globally not needed?

We are almost there, I am getting a syntax error but don't have solution. The User2.PASS has info coming from the Public declaration.

Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("ztblUserLog", dbOpenDynaset)
With rst
.FindLast "PASS] = " & User2.PASS <===== Once I pass this point on the debugging, gives me "syntax error.
.Edit
!TimeOut = Now()
.Update
End With

On the password on tracking function, I could have use the Id (numbers and Letters combi) but I preferred to used the password because it contains user names. I created it that way for users not to forget their password and I could easily identify them. Thank you again.
 
It's able to hold and retrieved information from memory, I followed your suggestion to: me.form.visible = false (frmLogon form). In this case, I could have reference the data directly from the password textbox on the frmLogon form, so that makes my Public User-type declaration on the module globally not needed?

We are almost there, I am getting an error but don't have solution. The User2.PASS has info coming from the Public declaration.

Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("ztblUserLog", dbOpenDynaset)
With rst
.FindLast "PASS = " & User2.PASS <===== Once I pass this point on the debugging, it gives me this error, "The MS jet engine does not recognized "Admin" as a valid field name or expression" Admin = the password keep in memory

.Edit
!TimeOut = Now()
.Update
End With

On the password on tracking function, I could have use the Id (numbers and Letters combi) but I preferred to used the password because it contains user names. I created it that way for users not to forget their password and I could easily identify them. Thank you again.
 
I think the problem with your syntax error, might be the PASS variable being a string (alpha-numeric text).

Change the line that is giving you this error to (adding the apostrophe's)
Code:
.FindLast "PASS = '" & User2.PASS & "'"
 
Rolaaus

:)Kudos to you! It took me many days working hours here and there, until I acknowledged I needed help. I appreciate it!
 
Thanks, I've been doing this long enough for me to know what I know, and know what I don't know ;-) I still post in these and other boards/forumns when I'm stuck eventhough I've been doing this stuff for about 15 years.
 

Users who are viewing this thread

Back
Top Bottom