.
Here are two projects you might be able to use to get started with. I've not utilized a CARD READER so won't be of any assistance to you.
However, if you can get the card data to populate the correct fields, shouldn't be a problem ?
This is only one example macro. There are two projects attached :
Option Explicit
Dim CM As Boolean
Private Sub cmdLogin_Click()
With Worksheets("May_1st").Range("A65536").End(xlUp)
.Offset(1, 0) = UserForm1.txtName.Value
.Offset(1, 1) = UserForm1.txtEmpID.Value
.Offset(1, 2) = UserForm1.txtTime.Value
End With
'Unload Me 'Optional: Close Userform1
'cmdLogin.Enabled = False
txtName.Value = ""
txtEmpID.Value = ""
txtEmpID.SetFocus
End Sub
Private Sub cmdLogOut_Click()
'Worksheets("May_1st").Range("D65536").End(xlUp).Offset(1) = Format(Now, "hh:mm:ss")
'Unload Me 'Optional: Close Userform On Where Logout Button Is
Dim myLog As Worksheet
Dim myLogSheet As Range
Set myLog = Sheets("May_1st")
Set myLogSheet = myLog.Range("B:B").Find(txtEmpID.Value, , , xlWhole)
If Not myLogSheet Is Nothing Then
myLogSheet.Offset(0, 2) = Format(Now, "hh:mm:ss")
Else
txtName.Value = "XXX"
End If
txtName.Value = ""
txtEmpID.Value = ""
txtEmpID.SetFocus
End Sub
Private Sub txtEmpID_Change()
Dim mySheet As Worksheet
Dim myRange As Range
Set mySheet = Sheets("Emp_ID")
Set myRange = mySheet.Range("B:B").Find(txtEmpID.Value, , , xlWhole)
If Not myRange Is Nothing Then
txtName.Value = myRange.Offset(0, -1)
Else
txtName.Value = "Match not found"
End If
End Sub
Private Sub UserForm_activate()
'Do
'If CM = True Then Exit Sub
'txtTime = Format(Now, "hh:mm:ss")
'DoEvents
'Loop
Do While CM = False
UserForm1.txtTime = Format(Now, "hh:mm:ss")
DoEvents
Loop
'txtEmpID.SetFocus
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
CM = True
End Sub
Bookmarks