Private Sub cmdShip_Click()
On Error GoTo Err_cmdShip_Click
Dim stRptName As String, stParam As String, stLinkCriteria As String
Dim iPreview As Integer, iDialog As Integer
iPreview = 0
iDialog = 0
If Me.ChkPreview Then
iPreview = 2
iDialog = 3
End If
stRptName = "Main_by_Ship"
stParam = Replace(LCase(Me.cboShip.value), " ", "_")
stLinkCriteria = "[Ship] = '" & Me.cboShip.value & "'"
DoCmd.CopyObject , stParam, acReport, stRptName
DoCmd.OpenReport stParam, iPreview, , stLinkCriteria, iDialog
DoCmd.Close acReport, stParam
DoCmd.DeleteObject acReport, stParam
Exit_cmdShip_Click:
Exit Sub
Err_cmdShip_Click:
MsgBox Err.description
Resume Exit_cmdShip_Click
End Sub