Private Sub cmdClick_Click()
'*************************************************
'********** Declare Variables ************
'*************************************************
Dim ClockRecord As BadgeID
Dim JDate As String
Dim Date1 As Date
Dim MyYear As Integer
Dim EmpID As String
Dim RightNow, Hours, Minutes, Seconds
Dim BadgeRecord As Integer
'**************************************************
'********** Setup Variables ****************
'**************************************************
RightNow = Now
Hours = Right("00" + Trim(Str(Hour(RightNow))), 2)
Minutes = Right("00" + Trim(Str(Minute(RightNow))), 2)
Seconds = Right("00" + Trim(Str(Second(RightNow))), 2)
EmpID = Left(Right(BadgeSwipe.Text, 6), 5)
MyYear = Val(Right(Format(Date, "Long Date"), 4))
Date1 = "12/31/" + Str(MyYear - 1)
JDate = DateDiff("d", Date1, Now)
'**************************************************
'********** Validating Badge Swipe ********
'**************************************************
If Left(BadgeSwipe.Text, 1) <> "@" Then
Result = MsgBox("Error Reading Badge -- Press ENTER to Try Again!", vbOKOnly, "ERROR")
BadgeSwipe.Text = ""
BadgeSwipe.SetFocus
Exit Sub
End If
If Right(BadgeSwipe.Text, 1) <> "#" Then
Result = MsgBox("Error Reading Badge -- Press ENTER to Try Again!", vbOKOnly, "ERROR")
BadgeSwipe.Text = ""
BadgeSwipe.SetFocus
Exit Sub
End If
BadgeRecord = 0
For i = 1 To UBound(BadgeTable)
If BadgeTable(i) = EmpID Then
BadgeRecord = i
Exit For
End If
Next
If BadgeRecord > 0 Then
Open "c:\stores\timeclck\data\badges" For Random As #1 Len = Len(Badges)
Get #1, BadgeRecord, Badges
End If
If Right(BadgeSwipe.Text, 1) = "#" Then
'**************************************************
'********** Create Clock File *************
'**************************************************
ClockRecord.EmployeeID = EmpID
ClockRecord.EndofRec = Chr(13) + Chr(10)
ClockRecord.StoreNo = StoreNo
ClockRecord.ClockNo = ClockNo
ClockRecord.Date = LTrim(Str(MyYear)) + JDate
ClockRecord.Time = Hours & Minutes & Seconds
ClockRecord.Dummy1 = " "
ClockRecord.Dummy2 = " "
ClockRecord.Dummy3 = " "
ClockRecord.Dummy4 = " "
'**************************************************
'********** Open and Write Clock File *****
'**************************************************
FileName = "c:\stores\timeclck\data\clck" + StoreNo + Right(ClockNo, 1) + "." + JDate
Open FileName For Random As #1 Len = Len(ClockRecord)
FileLength = LOF(1)
LastRecord = FileLength / Len(ClockRecord) + 1
Put #1, LastRecord, ClockRecord
Close
BadgeSwipe.Text = ""
End Sub
Private Sub Form_Load()
Open "c:\stores\timeclck\data\badges" For Random As #1 Len = Len(Badges)
FileLength = LOF(1)
LastRecord = FileLength / Len(Badges)
For i = 1 To LastRecord
Get #1, i, Badges
BadgeTable(i) = Badges.EmpID
Next
Close
'***************LOAD ENVIROMENT VARIABLES
'****************FOR STORE NUMBER AND CLOCK NUMBER
StoreNo = Environ("STORENUM")
ClockNo = Environ("CLOCK")
End Sub
Private Sub Timer1_Timer()
If lblTime(1).Caption <> CStr(Time) Then
lblTime(1).Caption = Time
End If
'***************CLOSE PROGRAM AT DAY END
lbldate.Caption = Format(Date, "Long Date")
If Time = "12:00:00 AM" Then
End
End If
End Sub