ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Login date & time to the VBA application. (https://www.excelbanter.com/excel-programming/392559-login-date-time-vba-application.html)

[email protected]

Login date & time to the VBA application.
 
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


Bob Phillips

Login date & time to the VBA application.
 
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)

wrote in message
ups.com...
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




[email protected]

Login date & time to the VBA application.
 
On Jul 3, 11:00 am, "Bob Phillips" wrote:
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)

wrote in message

ups.com...



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- Hide quoted text -


- 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



All times are GMT +1. The time now is 08:49 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com