hi,
Im in the middle of doing a simple project.
The idea is something like a Daily Time Card (DTC) for employee. For it will record the daily time in/out of every employee.
The concept is, the user will log in with "UserID and Password" and the User's details will be recorded together with the time of logging in.
Im able to perform this one with the help of the related post.
Im having a problem in the area of log out.
That when the User logs out, by typing the UserID and password, it should record the time-out in the "TimeOUT" in the same row of the user's logs details.
Basic column i have for log info (password will not be display as it will be printed for reference, i record the account details in different sheet)
=======================================
Name | UserID | Date | Time IN | TimeOUT
=======================================
>>What happen is the Logout time displays in the LAST empty row of column "Time OUT" <<
I believed this one is quite simple to an expert one.
If I need to post my code i will, but for now i think you can help without my simple code
Thank you!
Excel 2007 - LogIn Logout
-
-
-
Re: Excel 2007 - LogIn Logout
Hi here i post my simple code as requested.
=====CODE FOR LOG IN=====Code
Display MoreOption Explicit Private Sub cmdCancel_Click() Unload Me End Sub Private Sub cmdOK_Click() Dim iFoundPass As Integer 'Dim LogIN 'Dim today On Error Resume Next With Sheets("UserAccount").Range("UserNames") iFoundPass = .Find(What:=txtusername, After:=.Cells(1, 1), LookIn:=xlValues, LookAt _ :=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _ False).Row End With On Error GoTo 0 If iFoundPass = 0 Then SomethingWrong Exit Sub End If If Sheets("UserAccount").Cells(iFoundPass, 2) <> txtpass Then SomethingWrong Exit Sub Else MsgBox "LogIn success", vbInformation, "LogIn Successful" 'Write in the cell to view the log in info Dim lrow As Long Dim ws As Worksheet Set ws = Worksheets("DTR") 'find empty cells to fill in with appropriate information to record/ no password will be recorded lrow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row 'copy data to DTR ws.Cells(lrow, 1).Value = Sheets("UserAccount").Cells(iFoundPass, 3) ws.Cells(lrow, 2).Value = Me.txtusername.Value ws.Cells(lrow, 3).Value = Now() 'clear the textboxes txtusername.Value = "" txtpass.Value = "" End If 'Write to a cell ' LIN = Now() 'Sheets("DTR").Range("fullname") = LogIN 'Exit the form 'Unload Me End Sub Private Sub txtpass_Change() cmdOK.Enabled = (txtusername.TextLength > 2 And _ txtpass.TextLength > 2) End Sub Private Sub fLogIN_QueryClose(Cancel As Integer, CloseMode As Integer) If CloseMode = 0 Then Cancel = True End Sub Private Sub txtusername_Change() cmdOK.Enabled = (txtusername.TextLength > 2 And _ txtpass.TextLength > 2) End Sub Private Sub SomethingWrong() MsgBox "Incorrect Username or Password.", vbCritical + vbInformation, "LogIn Error" txtusername.SetFocus End Sub Private Sub UserForm_Click() End Sub
======CODE FOR LOGOUT=====Code
Display MorePrivate Sub cmdexit_Click() Unload Me End Sub Private Sub cmdLogOUT_Click() Dim iFoundPass As Integer 'Dim LogIN 'Dim today On Error Resume Next With Sheets("UserAccount").Range("UserNames") iFoundPass = .Find(What:=txtusername, After:=.Cells(1, 1), LookIn:=xlValues, LookAt _ :=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _ False).Row End With On Error GoTo 0 If iFoundPass = 0 Then SomethingWrong Exit Sub End If If Sheets("UserAccount").Cells(iFoundPass, 2) <> txtpass Then SomethingWrong Exit Sub Else MsgBox "Log Out success", vbInformation, "Log Out Successful" 'Write in the cell to view the log out info Dim lrow As Long Dim ws As Worksheet Set ws = Worksheets("DTR") 'find empty cells to fill in with appropriate information to record/ no password will be recorded lrow = ws.Cells(Rows.Count, 4).End(xlUp).Offset(1, 4).Row 'copy data to DTR 'ws.Cells(lrow, 1).Value = Sheets("UserAccount").Cells(iFoundPass, 3) 'ws.Cells(lrow, 2).Value = Me.txtusername.Value 'ws.Cells(lrow, 3).Value = Now() 'write the log out time iin 4th ROW ws.Cells(lrow, 4).Value = Now() 'clear the textboxes txtusername.Value = "" txtpass.Value = "" End If 'Write to a cell ' LIN = Now() 'Sheets("DTR").Range("fullname") = LogIN 'Exit the form 'Unload Me End Sub Private Sub CommandButton1_Click() End Sub Private Sub txtpass_Change() cmdLogOUT.Enabled = (txtusername.TextLength > 2 And _ txtpass.TextLength > 2) End Sub Private Sub txtusername_Change() cmdLogOUT.Enabled = (txtusername.TextLength > 2 And _ txtpass.TextLength > 2) End Sub Private Sub UserForm_Click() End Sub Private Sub UserForm_Initialize() End Sub Private Sub SomethingWrong() MsgBox "Incorrect Username or Password.", vbCritical + vbInformation, "LogIn Error" txtusername.SetFocus End Sub
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!