error number 287

all,

 

Through error handling I use I got an error # 287. I usually go http://www.fmsinc.com/microsoftaccess/errors/ErrorNumber_Description2007.html for descriptions but this isn't listed. The description the error handling gave, which is listed a number of times, "Application-defined orobject defined error" which I understand since it was Access 2007 using Vba to create an email in Outlook 2010, and failed. I am more interested in why is not listed. Maybe there is an issue with my error handling or I'm missing something, any ideas?

thanks

here is the code, which was written by some else, i added the error handling to this error handling function:

Public Function ShowError(strModule As String, strForm As String, _
lngErrorNumber As Long, strErrorDescription As String)

'* Purpose: To create a central error handling mechanism.
'* Accepts: strModule - name of the module, where the error was from (form, class, ect)
'* strprocedure - the name of the procedure where the error occured
'* lngErrorNumber - the numeric error identifier
'* strErrorDescription - the text description of the error

On Error GoTo PROC_ERR
Dim strMessage As String
Dim strCaption As String

'* Build the error message
strMessage = "Pease look into this issue. " & vbCr & vbCr & _
                        "Please provide detailed information and explain exactly what you were doing when this error occurred.  the automatic information is limited when finding a solution." & vbCr & vbCr & _
                        "Error # " & lngErrorNumber & " : " & strErrorDescription & vbCr & _
                        "Module: " & strModule & vbCr & _
                        "Form: " & strForm


'* Build the caption for the msgbox
strCaption = "Unexpected Error! "

'MsgBox strMessage, vbCritical, strCaption
Dim myMail As MailItem
'Set objOutlook = CreateObject("Outlook.Application")
Set myMail = CreateItem(olMailItem)
With myMail
        .Recipients.Add ("XXX")
     .Subject = strCaption
        .Body = strMessage
        .Display
        '.Send
End With
MsgBox "Please Send Error Email", vbCritical, strCaption
PROC_EXIT:
    Exit Function
PROC_ERR:
Select Case lngErrorNumber
Case 462
    MsgBox "Emails cannot be created.  Please restart the DB, then try again.", vbCritical, "Email Error, a message from the IT Dept."
    GoTo PROC_EXIT
Case Else
    MsgBox "It seems there may be a problem sending emails so please get this info to IT Module: " & strModule & " Error # " & lngErrorNumber & " : " & strErrorDescription, vbCritical, "Error- in error handling"
    GoTo PROC_EXIT
End Select
End Function

 

Question Info


Last updated August 28, 2018 Views 2,207 Applies to:

* Please try a lower page number.

* Please enter only numbers.

* Please try a lower page number.

* Please enter only numbers.

It isn't clear to me from your post whether error number 287 is being raised elsewhere in the application and passed to your ShowError function, or whether the error is being raised inside the ShowError function itself.  Could you clarify that for me, please, and indicate which line of code is actually raising the error?  You may need to set a breakpoint in the function and step through the code to see where the error occurs.

 

Dirk Goldgar, MS Access MVP 2001-2015
Access tips: www.datagnostics.com/tips.html

Did this solve your problem?

Sorry this didn't help.

Great! Thanks for marking this as the answer.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this response?

Thanks for your feedback.

dirk,

 

You are correct the error is happeni ng in a different function, then being passed to the show error handler.  this is the code where is orignates.  i can only guess at the line and do not have access to replicate my guess is on Set myMail = CreateItem(olMailItem):

 

Function OutFlowCheck()
On Error GoTo PROC_ERR

Dim myMail As MailItem
Dim rs As DAO.Recordset
Set rs = CurrentDbC.OpenRecordset("Acct_Admin_Tracking_Check")
If Nz(rs.Fields("Out Flow"), 0) - Nz(rs.Fields("Out Flow Processed"), 0) = 0 And Nz(rs.Fields("CountNoteOut"), 0) - Nz(rs.Fields("ProcNoteout"), 0) = 0 Then
                    DoCmd.OpenQuery "Acct_Mark_OutFlow", acViewNormal, acEdit
                    Set objOutlook = CreateObject("Outlook.Application")
                    Set myMail = CreateItem(olMailItem)
                    myMail.Recipients.Add (XXX)
                    myMail.Recipients.Add (YYY)
                    myMail.Subject = rs.Fields("Firm_Name") & " Out Flow is ready to be reviewed."
                    myMail.HTMLBody = myMail.HTMLBody
                    myMail.Display
                    'myMail.Send
                Else:
                    Dim msgStr As String
                    If Nz(rs.Fields("CountNoteOut"), 0) - Nz(rs.Fields("ProcNoteOut"), 0) > 0 Then
                    msgStr = "Out Flow Notes still need to be processed." & vbCr & vbCr
                    End If
           
                    If Nz(rs.Fields("Out Flow"), 0) - Nz(rs.Fields("out Flow Processed"), 0) > 0 Then
                    msgStr = msgStr & "Out Flow Inventory still needs to be processed." & vbCr & vbCr
                    End If
                   
                    MsgBox msgStr, vbOKOnly, "Tracking"
                    msgStr = ""
                  
End If
GoTo PROC_EXIT
PROC_EXIT:
rs.Close: Set rs = Nothing
Exit Function
PROC_ERR:

Call ShowError("OutFlowCheck", Nz(Screen.ActiveForm.Name, "No Active Form"), Err.number, Err.Description)
GoTo PROC_EXIT
End Function

 

i can say that the error occurred after outlook asked for "a program is trying to access..." with  allow and deny options, and the user closed it.  sorry the pic is so bad:

 

Did this solve your problem?

Sorry this didn't help.

Great! Thanks for marking this as the answer.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this response?

Thanks for your feedback.

Thanks for sharing the code.

 

If you want to know where the error occurs, set a breakpoint at the top of the procedure, run the code, and carefully step through, inspecting variables, expected program flow, etc.

 

I see some code that causes concern, although perhaps not error 287. The general comment is that this code lacks defensive programming techniques.

 

#1 Set rs = CurrentDbC
This could be completely legitimate if CurrentDbC has been declared at a global level. It's a bit suspect because VBA has CurrentDb and this could be a misspelling. Make sure "Option Explicit" is at the top of every module.

 

#2: Set rs = CurrentDbC.OpenRecordset
If Nz(rs.Fields("Out Flow"), 0)
After opening a recordset it is unsafe to assume records were returned and you can access the first record. Rather one should test for rs.EOF.

 

#3: Set objOutlook = CreateObject("Outlook.Application")
Set myMail = CreateItem(olMailItem)
Same comment: CreateObject may fail. If you want to use a possible already running instance of Outlook you should use GetObject.

 

#4: Set objOutlook = CreateObject("Outlook.Application")
We expect objOutlook is declared at the global level, but the real issue here is that you (the previous dev) are mixing early and late binding. This line is late binding, the next one requires early binding (or olMailItem would not be defined).

 

-Tom.
Microsoft Access MVP
Phoenix, AZ

Did this solve your problem?

Sorry this didn't help.

Great! Thanks for marking this as the answer.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this response?

Thanks for your feedback.

tom,

 

thanks for the reply.

 

#1 is a global variable and option explicit is at the top.

 

#2 this is a count query and with the table setup will return something. if that particular field if there is nothing to count its blank so i use the NZ function to return 0.  i realize i could probably do this is the query.

 

#3 ok, i suppose i could use this change i found 

 

On Error Resume Next
Set objOutlook= GetObject(, "Outlook.Application")

If Err.Number = 429 Then
Set objOutlook = CreateObject("Outlook.application")
End If

 

#4 actually objOutlook  is not set as a global variable.   should i add 'Dim objOutlook As Object'?  although i have read the difference between late and early binding it has alwasys flumuxed me.  i even just went back and found a helpful article i still don't know who to change it.  Other parts of my code use Set myMail = CreateItem(olMailItem)  and it fails often.  i have not had a good way of fixing except warning the user, having them close the DB, open it and try again.  what would you suggest?

 

thanks

 

edit 9/18/2013 12:06 pm et

 

so i found at http://msofficefun.wordpress.com/2011/02/26/early-binding-vs-late-binding-in-office-vba/  this, would it be better?:

In other words, if an object variable is defined and instantiated as such:

Dim objExcel as object

Set objExcel = CreateObject("Excel.Application")

then it counts as late bound, whereas defining and instantiating it in this way:

Dim objExcel as Excel.Application

Set objExcel = New Excel.Application

counts as early bound.

Did this solve your problem?

Sorry this didn't help.

Great! Thanks for marking this as the answer.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this response?

Thanks for your feedback.

#1 Set rs = CurrentDbC
This could be completely legitimate if CurrentDbC has been declared at a global level. It's a bit suspect because VBA has CurrentDb and this could be a misspelling. Make sure "Option Explicit" is at the top of every module.

 


CurrentDbC is the name MichKa gave to his posted solution to the inefficiency issue with repeated calls to CurrentDb.  It's a Property Get procedure that refers to a private, module-level database variable that is set from CurrentDb only when it is Nothing.  I use this method extensively, and I'll bet that's what Tighe Voss is using.
Dirk Goldgar, MS Access MVP 2001-2015
Access tips: www.datagnostics.com/tips.html

Did this solve your problem?

Sorry this didn't help.

Great! Thanks for marking this as the answer.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this response?

Thanks for your feedback.

absolutey Dirk.

Did this solve your problem?

Sorry this didn't help.

Great! Thanks for marking this as the answer.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this response?

Thanks for your feedback.

i can say that the error occurred after outlook asked for "a program is trying to access..." with  allow and deny options, and the user closed it.  sorry the pic is so bad:

 


Well, then!  That seems to be the cause of the error, and it makes perfect sense.  You are automating Outlook to generate an e-mail, Outlook security kicks in and displays the dialog, and by cancelling the dialog -- or clicking "Deny" -- the user keeps Outlook from doing what you told it.  Outlook then raises error 287, though there is no special message defined for it, just the default "Application-defined or object-defined error" message.

 

I just set up a simple test and was able to reproduce this exact error.  If I click "Allow" on the security dialog, though, no error is raised.

 

Dirk Goldgar, MS Access MVP 2001-2015
Access tips: www.datagnostics.com/tips.html

Did this solve your problem?

Sorry this didn't help.

Great! Thanks for marking this as the answer.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this response?

Thanks for your feedback.

dirk,

 

any ideas on how to supress the dialog if it pops up (i have had only one user notify me) or continue after the error occurs?

1 person was helped by this reply

·

Did this solve your problem?

Sorry this didn't help.

Great! Thanks for marking this as the answer.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this response?

Thanks for your feedback.

This utility works around it: http://dimastr.com/redemption/home.htm

Highly recommended.

-Tom.
Microsoft Access MVP
Phoenix, AZ

Did this solve your problem?

Sorry this didn't help.

Great! Thanks for marking this as the answer.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this response?

Thanks for your feedback.

thanks tom. 

Did this solve your problem?

Sorry this didn't help.

Great! Thanks for marking this as the answer.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this response?

Thanks for your feedback.

* Please try a lower page number.

* Please enter only numbers.

* Please try a lower page number.

* Please enter only numbers.