0

me.combo box次のコードでmy が選択されていない場合、エラー メッセージを追加しますか?

Private Sub Command1_Click()
Dim Recipient As String
Dim RecipientCC As String
Recipient = Me.Combo10.Column(2)
RecipientCC = Me.Combo10.Column(3)
Dim DateText As String
DateText = Format(Date - IIf(Weekday(Date) < 3, 1 + Weekday(Date), 1), "MM-DD-YYYY")

DoCmd.TransferText acExportDelim, , "watchdog", "G:\Common\Auto Finance\WatchDog\watchdog_" & [DateText] & ".csv", True

    'send email
    Dim olApp As Outlook.Application
    Dim olMail As Outlook.MailItem

     'get application
    On Error Resume Next
    Set olApp = GetObject(, "Outlook.Application")
    If olApp Is Nothing Then Set olApp = New Outlook.Application
    On Error GoTo 0

    Set olMail = olApp.CreateItem(olMailItem)
    With olMail
        .Subject = "Indirect Auto Watchdog File"
        .Recipients.Add [Recipient]
        .CC = [RecipientCC]
        .Attachments.Add "G:\Common\Auto Finance\WatchDog\watchdog_" & [DateText] & ".csv"
        .Body = ""
        .Display 'This will display the message for you to check and send yourself
         '.Send ' This will send the message straight away
    End With

MsgBox "Email Sent"
End Sub
4

1 に答える 1

0

if...else ループを追加しないのはなぜですか?

Private Sub Command1_Click()

if me.combobox.value<>"" then
   'do your task here
else
   'display error message
end if
End Sub
于 2013-05-16T07:50:58.577 に答える