-
September 21st, 2012, 02:33 PM
#1
[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
-
September 21st, 2012, 02:36 PM
#2
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"
-
September 21st, 2012, 04:45 PM
#3
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*
-
September 28th, 2012, 01:52 PM
#4
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.
-
September 28th, 2012, 02:54 PM
#5
Re: Run-time Error 2498
Like I said. Thank the spammers for the 'feature'
-
September 28th, 2012, 02:56 PM
#6
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.
-
September 28th, 2012, 03:03 PM
#7
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|