'------------------------------------------------------------
' cmdSendReport_Click
'
'------------------------------------------------------------
Private Sub cmdSendReport_Click()
Dim varName As String
Dim intNumOfRecs As Integer
Dim intResponse As Integer
varName = Me![txtName]
If IsNull(varName) Then
MsgBox "You must enter a Name", vbExclamation, "No Name Entered"
Me![txtName].SetFocus
Exit Sub
End If
Do
intNumOfRecs = DCount("*", "qSalesQueryLastName", "[Name] = '" & varName & "'")
If intNumOfRecs = 0 Then
intResponse = MsgBox("No Records exists for a Name of [" & varName & "], try again?", _
vbQuestion + vbYesNo + vbDefaultButton1, "Parameter Prompt")
If intResponse = vbYes Then Me![txtName].SetFocus: Exit Sub
Else
'Record(s) exist, Run Macro or execute code here
On Error GoTo cmdSendReport_Click_Err
DoCmd.OpenReport "PurchaseByPerson", acViewPreview
intResponse = MsgBox("EMail Report?", vbQuestion + vbYesNo, "E-Mail Confirmation")
If intResponse = vbYes Then
DoCmd.Close acReport, "PurchaseByPerson"
DoCmd.SendObject acReport, "PurchaseByPerson", "PDFFormat(*.pdf)", "", "", "", "Dina poster", _
"Härär dem poster du har köpt av CBC", True, ""
Else
DoCmd.Close acReport, "PurchaseByPerson"
Exit Sub
End If
End If
cmdSendReport_Click_Exit:
Exit Sub
cmdSendReport_Click_Err:
MsgBox Error$
Resume cmdSendReport_Click_Exit
Loop Until intNumOfRecs > 0 Or intResponse = vbNo
End Sub