+ Reply to Thread
Results 1 to 2 of 2

Runtime Error Help

  1. #1
    Registered User
    Join Date
    08-23-2005
    Posts
    53

    Runtime Error Help

    The following code emails with attachment, however about 10 emails in a get a 2501 runtime error, can someone help it's driving me crazy?


    Private Sub Command134_Click()
    Dim MyDb As DAO.Database
    Dim rsEmail As DAO.Recordset
    Dim sToName As String
    Dim sSubject As String
    Dim sMessageBody As String


    Set MyDb = CurrentDb()
    Set rsEmail = MyDb.OpenRecordset("Contractors With Jobs Not Atteded On Time", dbOpenSnapshot)

    Do Until rsEmail.EOF
    Me.Combo130 = rsEmail!Contractor
    sToName = rsEmail!Email
    sSubject = "Jobs Not Achieving Attended On Time " & rsEmail!Email
    sMessageBody = "Please Find Attached Jobs Not Achieving Attended On Time " & rsEmail!Contractor

    Const cTIME = 1500 'in MilliSeconds
    Call sSleep(cTIME)

    DoCmd.SendObject acSendReport, "Jobs Not Achieving Attended On Time", acFormatRTF, sToName, , , sSubject, sMessageBody, False, False

    rsEmail.MoveNext
    Loop

    Set MyDb = Nothing
    Set rsEmail = Nothing
    End Sub

  2. #2
    Forum Contributor
    Join Date
    04-23-2009
    Location
    IOWA
    MS-Off Ver
    2010 Professional
    Posts
    270

    Re: Runtime Error Help

    I see no error handling in it. What happens if one of your contractors email address isn't on file? It has no instructions on what to do if an error occurs. So if a message fails to send for whatever reason it will stop, vs continuing and then telling you which messages failed to send.

    Hope this helps,

    Dan
    "I am not a rocket scientist, I am a nuclear engineer." - Split_atom18
    If my advice has been helpful to you, then please help me by clicking on the "Star" and adding to my reputation, Thanks!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1