history problem

javier_83

Registered User.
Local time
Today, 09:09
Joined
Jul 9, 2008
Messages
49
Hi i have a form, that ask me my username and password, and works perfect, also save me a history record, of who enter to the sistem and what time and what date, that also works fine i use this

Dim rst As DAO.Recordset
Set rst = CurrentDb.TableDefs("historialacceso").OpenRecordset
rst.AddNew
rst!Username = Me.cmbLogin
rst!Fecha = Now()
rst!Hora = Now()
rst.Update
rst.Close
Set rst = Nothing

now i want to add a history when people enter to a seccion of the program so i use this


Dim rst As DAO.Recordset
Dim var As Variant
var = DLookup("[username]", "historialacceso", "0")
Set rst = CurrentDb.TableDefs("historial_registroasset").OpenRecordset
rst.AddNew
rst!Username = var
rst!Fecha = Now()
rst!Hora = Now()
rst.Update
rst.Close
Set rst = Nothing

i use dlookup to find the username, because i close the form, wheere i copy to the first history table!

but, my problem is this one, how can i use the dlookup to search fro the last record of the history table??
 
perhaps you could not close the login form, just make it invisible. then you can get the user name from the form and search for the max date for that user (if necessary). you just need the user name?
 
Jav ... if you are using my demo db and using the global variable ... you have the user name in memory the entire time they are logged in.

Again, if you are using that technique .. check the module for the global variables.

If not, I return you back to where you are.

-dK
 
thanks dk, i made another variable, because i change the db that you use, but i do that i made another variable and works perfect! thanks
 

Users who are viewing this thread

Back
Top Bottom