Private Sub cmdAdd_Click()
'Add item to database
cmdAdd.Enabled = False
cmdSave.Enabled = True
cmdDelete.Enabled = True
dtaInventory.Recordset.AddNew
txtItem.SetFocus
End Sub
Private Sub cmdDelete_Click()
'Delete item from database
Dim Rvalue As Integer
Rvalue = MsgBox("Are you sure you want to delete this item?", vbQuestion + vbYesNo, "Delete Item")
If Rvalue = vbNo Then Exit Sub
dtaInventory.Recordset.Delete
dtaInventory.Recordset.Requery
dtaInventory.Recordset.MoveNext
If dtaInventory.Recordset.EOF = True Then
dtaInventory.Refresh
If dtaInventory.Recordset.BOF = True Then
MsgBox "You must add a record.", vbOKOnly + vbInformation, "Empty File"
Call cmdAdd_Click
Else
dtaInventory.Recordset.MoveFirst
End If
End If
txtItem.SetFocus
End Sub
Private Sub cmdNext_Click()
'Move to next item
dtaInventory.Recordset.MoveNext
If dtaInventory.Recordset.EOF Then dtaInventory.Recordset.MovePrevious
txtItem.SetFocus
End Sub
Private Sub cmdPrevious_Click()
'Move to previous item
dtaInventory.Recordset.MovePrevious
If dtaInventory.Recordset.BOF Then dtaInventory.Recordset.MoveNext
txtItem.SetFocus
End Sub
Private Sub cmdSave_Click()
'Check txtItem has been filled
If txtItem.Text = "" Then
Dim Response As Integer
Response = MsgBox("Please enter an item", vbOKOnly + vbCritical, "Add item")
Else
'Save item to database
dtaInventory.Recordset.Update
dtaInventory.Recordset.Requery
cmdAdd.Enabled = True
cmdSave.Enabled = False
cmdDelete.Enabled = True
txtItem.SetFocus
End If
End Sub
Private Sub mnuExit_Click()
'Exit Program
Dim Response As Integer
Response = MsgBox("Are you sure you want to exit?", vbYesNo + vbCritical + vbDefaultButton2, "Exit Program")
If Response = vbNo Then
Exit Sub
Else
End
End If
End Sub
Private Sub mnuPrint_Click()
'Show Printable Inventory
dtaInventory.Recordset.Requery
rptInventory.Refresh
rptInventory.Show
End Sub