473,287 Members | 1,689 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

Runtime Error 2487

DJRhino1175
221 128KB
I'm getting runtime Error 2487: The object Type argument for the action or method is blank or invalid

It triggers at line 36

I have been using this code for awhile, but all of a sudden it stopped working. Can anyone see something I have wrong?

Expand|Select|Wrap|Line Numbers
  1. Private Sub btnAuditEmail_Click()
  2.  
  3.     On Error GoTo Error
  4.  
  5.     Dim strEMail        As String
  6.     Dim strSubject      As String
  7.     Dim strBody         As String
  8.     Dim MyDB            As DAO.Database
  9.     Dim rstEMail        As DAO.Recordset
  10.     Dim strReportName   As String
  11.     Dim myReportWhere   As String
  12.     Dim myOutPutFile    As String
  13.     Dim aFile           As String
  14.     Dim strAtch         As String
  15.     Dim strMsg          As String
  16.  
  17.  
  18.         strMsg = "No Reject Tag Number. Please fill out the whole Reject Tag. Then try to resend"
  19.  
  20.         strReportName = _
  21.             Replace(Replace("REJECT TAG#|1 PN |2", "|1", Nz(" " & _
  22.             [REJECT TAG NUMBER], " ")), "|2", Nz([Part Number] & _
  23.             " " & [Descriptive Reason], " "))
  24.  
  25.         myReportWhere = "[REJECT TAG NUMBER] = [Forms]![Reject Tag Form Edit]![REJECT TAG NUMBER]"
  26.  
  27.         DoCmd.OpenReport _
  28.             ReportName:="Reject Tag Report", _
  29.             View:=acViewPreview, _
  30.             WhereCondition:=myReportWhere, _
  31.             WindowMode:=acWindowNormal
  32.  
  33.         myOutPutFile = "M:\Inspect\New Reject Tag Database\Reports" & _
  34.             "\" & strReportName & ".PDF"
  35.  
  36.         DoCmd.OutputTo _
  37.             Objecttype:=acOutputReport, _
  38.             Outputformat:=acFormatPDF, _
  39.             Outputfile:=myOutPutFile, _
  40.             AutoStart:=False, _
  41.             Outputquality:=acExportQualityPrint
  42.  
  43.         DoCmd.Close _
  44.             Objecttype:=acReport, _
  45.             ObjectName:="Reject Tag Report", _
  46.             Save:=acSaveNo
  47.  
  48.  
  49.         'Retrieve all E-Mail Addressess in tblEMail4
  50.  
  51. Set MyDB = CurrentDb
  52. Set rstEMail = MyDB.OpenRecordset("Select * From tblEMail4", _
  53.                 dbOpenSnapshot, dbOpenForwardOnly)
  54.  
  55. With rstEMail
  56.   Do While Not .EOF
  57.  
  58.     'Build the Recipients String
  59.     strEMail = strEMail & ![EmailAddress] & ";"
  60.       .MoveNext
  61.   Loop
  62. End With
  63.         Call MyDB.Close
  64.         Set rstEMail = Nothing
  65.         Set MyDB = Nothing
  66.  
  67.         strBody = _
  68.             "Please review the attached Reject Tag."
  69.         strSubject = _
  70.             Replace(Replace("REJECT TAG#|1 PN |2", "|1", Nz(" " & _
  71.             [REJECT TAG NUMBER], " ")), "|2", Nz([Part Number] & _
  72.             " " & [Descriptive Reason], " "))
  73.         strAtch = _
  74.             "M:\Inspect\New Reject Tag Database\Reports" & _
  75.             "\" & strReportName & ".PDF"
  76.  
  77.            Call SendAnEmail(olSendTo:=strEMail, _
  78.                          olSubject:=strSubject, _
  79.                          olEMailBody:=strBody, _
  80.                          olAtchs:=strAtch, _
  81.                          olDisplay:=True, _
  82.                          SendAsHTML:=True)
  83.  
  84.         aFile = _
  85.             "M:\Inspect\New Reject Tag Database\Reports" & _
  86.             "\" & strReportName & ".PDF"
  87.         If Len(Dir$(aFile)) > 0 Then _
  88.              Call Kill(PathName:=aFile)
  89.  
  90. Error:
  91.    MsgBox strMsg, vbCritical, "No Reject Tag number"
  92.    Exit Sub
  93. End Sub
Sep 28 '22 #1
6 21987
isladogs
454 Expert Mod 256MB
Hi
Apologies that your post ended up in the moderation queue and that there was a delay in approving it.
Hopefully it will be answered soon
Sep 29 '22 #2
DJRhino1175
221 128KB
I ended up figuring it out...Thanks
Oct 3 '22 #3
isladogs
454 Expert Mod 256MB
Congratulations.
It may be helpful to others if you could explain what your solution was.
Oct 3 '22 #4
NeoPa
32,554 Expert Mod 16PB
Hi DJ.

I assume you found that one of the values you passed as a parameter was invalid for that command. Can you confirm?
Oct 23 '22 #5
DJRhino1175
221 128KB
That would be my guess. I just kept tinkering till it just decided to work. I believe it was in my filter somewhere.
Oct 24 '22 #6
NeoPa
32,554 Expert Mod 16PB
Hi DJ.

Frustrating, but I absolutely know what you mean :-D

Great that it's sorted anyway.
Oct 24 '22 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Bob Bamberg | last post by:
Hello All, I have been trying without luck to get some information on debugging the Runtime Error R6025 - Pure Virtual Function Call. I am working in C++ and have only one class that is derived...
7
by: wmkew | last post by:
Hello everyone I'm encountering a R6002 Runtime error and several bugs when trying to generate a simple Managed C++ application with .NET 2003. The main problem seems to arise from linking with...
7
by: Yongsub Eric Shin | last post by:
Hi. I'm just a beginner in ASP.Net. I started writing codes and I keep on getting this Runtime Error page, where it says "Description: An application error occurred on the server. The current...
7
by: yuanlinjiang | last post by:
I am working on converting a win32 console application from VC6 to VC7. My version is Microsoft Development Environment 2003 version 7.1.3088. The code works fine on VC6. it is a console...
2
by: Aleksandar | last post by:
Hi, I need to convert set of Java classes exported from IBM Modeling environment to C# for implementation. When I invoke JCLA conversion from File->Open->Convert in Visual Studio 2005 it starts...
8
by: g_man | last post by:
I am trying trap Runtime error 3022 (duplicates) in the click event of a command button that closes the form. I have code in the Form_Error event that does a good job of providing a more meaningful...
7
by: John | last post by:
Hi Everyone, I'm having this extremely annoying problem with Internet Explorer 6, giving me an error message saying "unknown runtime error" whenever I try to alter the contents of a <divelement...
3
by: Jim Armstrong | last post by:
Hello all - This is driving me crazy. I have a table called tblClients - very simple, has the following fields: taxID (PK) ClientName SalesName The main form of my application allows a...
2
by: blogman | last post by:
I am getting a Visual studio 2008 IDE application R6034 runtime error. This means that the IDE application is raising the error not the application I am building. This means that Microsoft did not...
1
by: abhijaiswal | last post by:
Hi All, I am working on a project where I used to views (view1 and view2). I set my first page as view2. I have around 10 Textboxes, 5 dropdown, 4 List view and 6 buttons. When I run my web...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.