[RESOLVED] Run-time Error 2498
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: [RESOLVED] Run-time Error 2498

  1. #1
    Join Date
    Aug 2012
    Location
    Lubbock, TX
    Posts
    15

    [RESOLVED] Run-time Error 2498

    I am working on some code that will send an e-mail through Outlook 2003 "On Click" of a button inside of a form in my 2003 Access db. The code was in a different database, and was working just fine, but now that I have moved it into the new db, I am having problems. I have checked and changed form names several times, so I am sure that the error has nothing to do with that. It is throwing the flag on the line that actually sends the e-mail.
    The e-mail sends just fine, and even includes the form I want as an attachment, but keep getting an error message titled "Run-time Error 2498" once VB runs through the code. As far as functionality goes, there is no problem, but this is certainly annoying, and would like for it to stop.
    Any help is greatly appreciated.

    Code:
    Option Compare Database
    ' Chad Jackson
    ' 9/21/2012
    ' 5-Day E-Mail Notification
    ' This program finds all tickets that have been out for 5 days or longer,
    ' and then sends an e-mail to a pre-defined list of people.
    ' The purpose of this program is to help ensure a 5-day ticket turnaround time.
    '
    Private Sub btnSendEmail_Click()
    
        Dim rs As DAO.Recordset
        Dim stDocName As String
        Dim StrAttach As String
        Set rs = CurrentDb.OpenRecordset("5-Day E-Mail Addresses")
        With rs
            If .EOF And .BOF Then ' If there are no records, the message from the next line will display.
            MsgBox " No emails will be sent because there are no records from the query '5 Day Ticket Notification' "
        Else
            Do Until .EOF ' Do until the end of the recordset
    
    
            ' The next line sends the E-Mail
            DoCmd.SendObject acSendForm, "5 Day Ticket Notification", , ![E-Mail Address], , , "5-Day Reminder!", "Hello " & ![First Name] & ", " & Chr(10) & "You have tickets that have been out for 5 days or longer. Please get them processed as soon as possible.", False
            .MoveNext ' Moves to the next record in the recordset
            Loop
        End If
    End With
    
    ' Memory Clean Up
    If Not rs Is Nothing Then
        rs.Close
        Set rs = Nothing
    End If
    End Sub
    Name:  Error.JPG
Views: 782
Size:  23.4 KB

  2. #2
    Join Date
    Aug 2012
    Location
    Lubbock, TX
    Posts
    15

    Re: Run-time Error 2498

    Sorry, forgot to specify in the code which line is causing problems.
    It is the line that starts with, "DoCmd.SendObject acSendForm,..."
    It comes directly after the comment " The next line sends the E-Mail"

  3. #3
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,982

    Re: Run-time Error 2498

    Does it send the first one? Try to send ONE ONLY. Probably need to wait 15 seconds before sending another. Depending on Outlook, you might NOT be able to program it to send e-mails. Thank the spammers for that *feature*
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  4. #4
    Join Date
    Aug 2012
    Location
    Lubbock, TX
    Posts
    15

    Re: Run-time Error 2498

    It sends the email to all the people in the table just fine.
    The issue I'm having is the annoying error message that pops up regardless of the fact that the program runs just fine.

  5. #5
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,982

    Re: Run-time Error 2498

    Like I said. Thank the spammers for the 'feature'
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  6. #6
    Join Date
    Aug 2012
    Location
    Lubbock, TX
    Posts
    15

    Re: Run-time Error 2498

    But wait! It gets weirder...
    I have another program that is almost identical to this, only it sends an email out for tickets that have been out for 10 days instead of 5. The code for the 10 day notification runs just fine, no error messages or flaws of any kind. The code looks almost identical, except it looks through a recordset titled "10-Day E-Mail Addresses" instead of the "5-Day E-Mail Addresses" this code looks through. Makes no sense to me.

  7. #7
    Join Date
    Aug 2012
    Location
    Lubbock, TX
    Posts
    15

    Re: Run-time Error 2498

    Figured it out.
    My table had an extra line item at the end with no data in it. VB was finding this "record" despite there being no data, and didn't know what to do with it, so it would throw that error. This explains why it would send to the other records in the table, yet still have an error.
    Anyways,
    Deleted the ghost line, and everything is running fine.
    Thank you for your help!

Tags for this Thread

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center