Private Sub CancelButton_Click()
Unload CheckOutAsset
End Sub
Private Sub CheckInButton_Click()
End Sub
[B]Private Sub CheckOutButton_Click()
Dim ws As Worksheet
Dim newLogRow As String
Dim availChange As Range
Set ws = Sheets("Log"): Set tbl = ws.ListObjects("EquipLog")
With tbl
RowRef = .ListRows.Count
.ListRows.Add
.DataBodyRange(RowIndex:=RowRef, columnindex:=1).Value = Me.StaffID
.DataBodyRange(RowIndex:=RowRef, columnindex:=2).Value = Me.AssetID
.DataBodyRange(RowIndex:=RowRef, columnindex:=3).Value = Me.DynLabelCondition.Caption
.DataBodyRange(RowIndex:=RowRef, columnindex:=4).Value = "Checked Out"
.DataBodyRange(RowIndex:=RowRef, columnindex:=5).Value = Format(Now(), "hh:mm:ss")
.DataBodyRange(RowIndex:=RowRef, columnindex:=6).Value = Format(Now(), "mm-dd-yyyy")
.DataBodyRange(RowIndex:=RowRef, columnindex:=7).Value = DynLabelName.Caption
.DataBodyRange(RowIndex:=RowRef, columnindex:=8).Value = DynLabelAsset.Caption
.DataBodyRange(RowIndex:=RowRef, columnindex:=9).Value = Application.UserName
End With
Set availChange = Sheets("Assets").Columns("A").Find(AssetID.Text, , xlValues, xlWhole, 1, 1, 0)
availChange.Offset(0, 4).Value = "Out"
availChange.Offset(0, 5).Value = DynLabelName
StaffID.Text = ""
AssetID.Text = ""
CheckOutAsset!StaffID.SetFocus
End Sub[/B]
Private Sub DeleteButton_Click()
Dim iExit As VbMsgBoxResult
Dim i As Integer
iExit = MsgBox("Are you sure you want to delete this record? It cannot be undone!", vbQuestion + vbYesNo, "Confirm Record Deletion")
With Me.assetLogDisplay
If .ListIndex > -1 Then
Sheet1.ListObjects(1).ListRows(.ListIndex + 1).Delete
End If
End With
End Sub
Private Sub Label3_Click()
End Sub
Private Sub SearchButton_Click()
End Sub
Private Sub StaffID_Change()
With Worksheets("Employees")
On Error Resume Next
If Len(StaffID.Text) > 0 Then
x = .Columns(1).Find(StaffID.Text, LookIn:=xlValues, Lookat:=xlWhole).Row
If x > 0 Then
DynLabelName.Caption = .Cells(x, 2).Value
Else
DynLabelName.Caption = "ID# Not Found"
End If
Else
DynLabelName.Caption = ""
End If
On Error GoTo 0
End With
If StaffID.Text > "" Then
AssetID.Enabled = True
Else
AssetID.Enabled = False
End If
End Sub
Private Sub AssetID_Change()
With Worksheets("Assets")
On Error Resume Next
x = .Columns(1).Find(AssetID.Text, LookIn:=xlValues, Lookat:=xlWhole).Row
assetName = .Cells(x, 2).Value
assetCond = .Cells(x, 4).Value
assetAvail = .Cells(x, 5).Value
outTo = .Cells(x, 6).Value
DynLabelAsset.Caption = assetName
DynLabelCondition.Caption = assetCond
If assetAvail = "In" And assetCond = "Good" And StaffID.Text > "" Then
CheckOutButton.Enabled = True
CheckOutButton.BackColor = &H80FF&
DynLabelAvailable.Caption = "Ready To Checkout!"
Else
CheckOutButton.Enabled = False
CheckOutButton.BackColor = &HC0C0C0
End If
If StaffID.Text > "" And assetAvail = "In" And assetCond = "Good" Then
CheckOutButton.Enabled = True
CheckOutButton.BackColor = &H8000&
DynLabelAvailable.Caption = "Ready To Checkout!"
ElseIf StaffID.Text > "" And assetAvail = "Out" And assetCond > "" Then
CheckInButton.Enabled = True
CheckInButton.BackColor = &H8000&
DynLabelAvailable.Caption = "Ready To Check Back In!"
ElseIf StaffID.Text > "" And assetAvail = "Repair" Then
CheckInButton.Enabled = True
CheckInButton.BackColor = &H8000&
DynLabelAvailable.Caption = "Has this item been repaired?"
Else
CheckOutButton.Enabled = False
CheckOutButton.BackColor = &HC0C0C0
CheckInButton.Enabled = False
CheckInButton.BackColor = &HC0C0C0
DynLabelAvailable.Caption = ""
End If
On Error Resume Next
End With
End Sub
Private Sub UserForm_Initialize()
Me.lblDate.Caption = "Today: " & Format(Now(), "mmm-dd-yyyy")
If StaffID.Text > "" Then
AssetID.Enabled = True
Else
AssetID.Enabled = False
End If
LastAddress = Sheet1.Range("EquipLog").End(xlUp).Address
assetLogDisplay.ColumnCount = 10
assetLogDisplay.ColumnWidths = "1.4in,1in,1in,1in,0.75in,1in,1.5in,1.5in,1.25in, 1in"
assetLogDisplay.RowSource = Sheet1.ListObjects(1).DataBodyRange.Address(1, 1, xlA1, True)
'assetLogDisplay.RowSource = "'" & "Log" & "'!" & Range("EquipLog").Address
CheckOutAsset!StaffID.SetFocus
End Sub