Login date & time to the VBA application.

S

shahzad4u_ksa

Hi,

I am new in VBA, I am developing a small program in Excel using some
Userforms and controls. I want to prepare a log sheet for in my vba
program shows the Login time and date, every time when the user load
the data base. and it note the start time and close time of the
database.

is it possible, and I want to know the username also, who use the
database and what time he used.

I prepared one userform for Login and Password procedure for different
users, with different access rights.

Pls help me in this regard. Thanks in advance.

Shahzad
Madinah
 
B

Bob Phillips

It is simple to write to a log file

Private Sub LogDetailsIn()
Const LOG_FILENAME As String = "LogFile.txt"
Dim iFile As Long

iFile = FreeFile
Open ThisWorkbook.Path & "\" & LOG_FILENAME For Append As #iFile
Print #iFile, envirn("Username") & " logged in at " & _
Format(Now, "dd-mmm-yyyy hh:mm:ss")
Close #iFile
End Sub

then a similar routine when closing the task.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
S

shahzad4u_ksa

It is simple to write to a log file

Private Sub LogDetailsIn()
Const LOG_FILENAME As String = "LogFile.txt"
Dim iFile As Long

iFile = FreeFile
Open ThisWorkbook.Path & "\" & LOG_FILENAME For Append As #iFile
Print #iFile, envirn("Username") & " logged in at " & _
Format(Now, "dd-mmm-yyyy hh:mm:ss")
Close #iFile
End Sub

then a similar routine when closing the task.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)











- Show quoted text -


Dear Bob,

Sorry I dont understand, where I put your code, and how it works.
shall I put this code in LoginUserform or where??

Pls give me some explanation how to use your code.

Regards.

shahzad
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top