Private Sub cmdMoveBox_Click()
On Error GoTo Err_cmdMoveBox_Click
'Sub allows user to move a box from one address to another.
'Limits ability to move boxes to users with a permission level of 3 or higher.
Dim strDocName As String
Dim strLinkCriteria As String
Dim lst As Access.ListBox
Set lst = Me.BoxList
Dim intUser As Integer
strDocName = "frmBoxMove"
'Check for user authorization to delete boxes.
intUser = Nz(DLookup("[Level]", "tluUsers", "[UserID]= '" & Environ("username") & "'"))
If intUser > 2 Then
'Check to see if any boxes have been selected.
If lst.ItemsSelected.Count = 0 Then
'Let the user know what is wrong.
MsgBox "No box has been selected to move."
'Exit the sub.
Exit Sub
'Check that no more than 1 box has been selected.
ElseIf lst.ItemsSelected.Count > 1 Then
'Let the user know what is wrong.
MsgBox "Please select only one box to move."
'Clear the listbox selections.
lst.SetFocus
lst.ListIndex = -1
'Exit the sub.
Exit Sub
'If only one box is selected open the move box form.
Else:
strLinkCriteria = "[BoxID]=" & Me!BoxList.Column(11)
DoCmd.OpenForm strDocName, , , strLinkCriteria
End If
Else:
MsgBox "Sorry, you are not authorized to move boxes."
End If
Exit_cmdMoveBox_Click:
Exit Sub
Err_cmdMoveBox_Click:
MsgBox Err.Description
Resume Exit_cmdMoveBox_Click
End Sub