Application defined or object defined error access

Access выдает ошибку application-defined or object-defined error MS Access Решение и ответ на вопрос 1684732

0 / 0 / 0

Регистрация: 10.02.2014

Сообщений: 5

1

14.03.2016, 16:13. Показов 2966. Ответов 6


Доброго времени суток!!!
Прошу помощи ибо поиск по форуму так и не помог(((
При выполнении кода access вот так ругается «application-defined or object-defined error»

Вложения

Тип файла: txt ns.txt (18.0 Кб, 8 просмотров)

__________________
Помощь в написании контрольных, курсовых и дипломных работ, диссертаций здесь



0



1265 / 447 / 129

Регистрация: 21.03.2013

Сообщений: 1,210

14.03.2016, 17:53

2

Цитата
Сообщение от Verdgiliy
Посмотреть сообщение

При выполнении кода access вот так ругается «application-defined or object-defined error»

ты бы хоть указал на какой строке происходит ошибка
в процедуре закоменть он еррор готу и в отладке тебе подсветиться строка с ошибкой — уже будет легче тебе помочь



2



Verdgiliy

0 / 0 / 0

Регистрация: 10.02.2014

Сообщений: 5

14.03.2016, 18:59

 [ТС]

3

Ошибку выдал на эту строку

SQL
1
wksSheet.Cells(6 + i, 5 + j).AddComment (rsd.Fields(16))



0



mobile

Эксперт MS Access

26772 / 14451 / 3192

Регистрация: 28.04.2012

Сообщений: 15,782

14.03.2016, 19:09

4

Когда выйдет на ошибку проверьте в Immediate количество полей у rsd. Если меньше 15, то ошибка в этом.

Visual Basic
1
?rsd.FIELDS.Count

Но не исключаю, что ошибка из-за того, что в поле Null, а не значение. Тогда вместо Null надо подставить пустую строку

Visual Basic
1
wksSheet.Cells(6 + i, 5 + j).AddComment (rsd.FIELDS(16) & "")



1



0 / 0 / 0

Регистрация: 10.02.2014

Сообщений: 5

14.03.2016, 19:55

 [ТС]

5

?rsd.FIELDS.Count[/quote]
Вернул 18

Цитата
Сообщение от mobile
Посмотреть сообщение

Visual BasicВыделить код
1
wksSheet.Cells(6 + i, 5 + j).AddComment (rsd.FIELDS(16) & «»)

Тоже не помогло((((

я конечно ламер но что то ни чего не помогает(((



0



mobile

Эксперт MS Access

26772 / 14451 / 3192

Регистрация: 28.04.2012

Сообщений: 15,782

14.03.2016, 20:06

6

Лучший ответ Сообщение было отмечено Verdgiliy как решение

Решение

Тогда превратим поле в строку. Видимо AddComment не принимает ничего кроме стринга

Visual Basic
1
wksSheet.Cells(6 + i, 5 + j).AddComment cstr(rsd.FIELDS(16) & "")



1



0 / 0 / 0

Регистрация: 10.02.2014

Сообщений: 5

14.03.2016, 20:51

 [ТС]

7

Спасибо ОГРОМНОЕ!!!!!



0



title keywords f1_keywords ms.prod ms.assetid ms.date ms.localizationpriority

Application-defined or object-defined error

vblr6.chm1011299

vblr6.chm1011299

office

4c1ea0e8-e6f6-a960-eb13-b4dfc2bf96fe

06/08/2017

high

This message is displayed when an error generated with the Raise method or Error statement doesn’t correspond to an error defined by Visual Basic for Applications. It’s also returned by the Error function for arguments that don’t correspond to errors defined by Visual Basic for Applications. Thus it may be an error you defined, or one that is defined by an object, including host applications like Microsoft Excel, Visual Basic, and so on. For example, Visual Basic forms generate form-related errors that can’t be generated from code simply by specifying a number as an argument to the Raise method or Error statement. This message has the following causes and solutions:

  • Your application executed an Err.Raisen or Errorn statement, but the number n isn’t defined by Visual Basic for Applications. If this was what was intended, you must use Err.Raise and specify additional arguments so that an end user can understand the nature of the error. For example, you can include a description string, source, and help information. To regenerate an error that you trapped, this approach will work if you don’t execute Err.Clear before regenerating the error. If you execute Err.Clear first, you must fill in the additional arguments to the Raise method. Look at the context in which the error occurred, and make sure you are regenerating the same error.

  • It may be that in accessing objects from other applications, an error was propagated back to your program that can’t be mapped to a Visual Basic error.

Check the documentation for any objects you have accessed. The Err object’s Source property should contain the programmatic ID of the application or object that generated the error. To understand the context of an error returned by an object, you may want to use the On Error Resume Next construct in code that accesses objects, rather than the On Error GoToline syntax.

List trappable errors for the host application

In the past, programmers often used a loop to print out a list of all trappable error message strings. Typically this was done with code such as the following:

For index = 1 to 500
    Debug.Print Error$(index)
Next index

Such code still lists all the Visual Basic for Applications error messages, but displays «Application-defined or object-defined error» for host-defined errors, for example those in Visual Basic that relate to forms, controls, and so on. Many of these are trappable run-time errors. Use the Help Search dialog box to find the list of trappable errors specific to your host application. Click Search, type Trappable in the first text box, and then click Show Topics. Select Trappable Errors in the lower list box and click Go To.

For additional information, select the item in question and press F1 (in Windows) or HELP (on the Macintosh).

[!includeSupport and feedback]

  • Remove From My Forums
  • Question

  • Hello all,

    I have an access application that allows for the user to Save the current form record and also generate an email. After clicking the command button they are asked to allow or deny the event.

    If the user clicks Deny they receive the error message «Run-time error ‘287’: Application-defined or object-defined error»

    The user can then either click End or Debug. If they click End there isn’t an issue. If they click Debug the VBA debugger is opened and the code is displayed. This could result in the users making changes to the application code and cause it to break
    further.

    How can I fix the VBA code so it works without this error appearing?

    The code is below and attached is the error message and the point the debugger picks up the error. Any assistance is appreciated.

    Private Sub Command75_Click()
    Dim stId As Integer
    Dim db As Database
    Dim rs As DAO.Recordset
    Dim appOutLook As Outlook.Application
    Dim MailOutLook As Outlook.MailItem
    Dim stText As String
    Dim stDefect As String
    Dim stGkOrder As Long
    '==Save the current record
    If Me.Dirty Then Me.Dirty = False
    Set appOutLook = CreateObject("Outlook.Application")
    Set MailOutLook = appOutLook.CreateItem(olMailItem)
    '==Set db = CurrentDb()
    '==Set rs = db.OpenRecordset("dbo.NonConfData")
    stId = Me.Id
    stDefect = Me.Combo45.Column(1)
    stGkOrder = Me.GKOrderNum
    stText = "NonConformance IR #" & " " & "Defect Category:" & stDefect & " " & "Against Order#" & stGkOrder
    With MailOutLook
        .BodyFormat = olFormatHTML
        .To = "capateam@company.com"
        ''.cc = ""
        ''.bcc = ""
        .Subject = "NonConformance Generated IR #" & stId
        .HTMLBody = stText
        .Send
    End With
    '==rs.Close


    Keith

    • Edited by

      Friday, December 27, 2013 9:13 PM

Answers

  • You need error handlers to properly manage errors.  Users should never see the End/Debug dialog.

    Here’s the basics:

    Function YourFunction()
      On Error Goto Error_Proc
    
      ' all your usual code goes here'
    
    
    Exit_Proc:
      'this is your exit portion'
      'all exits will be directed here'
      'use this to clean up any open objects'
      Exit Function
    Error_Proc:
      'this is your error handler'
      'with the On Error statement at the top,'
      'any errors jump to the specified label'
      ''
      'check errors:'
      Select Case Err.Number
        Case 287:
          Resume Exit_Proc 'ignore the error'
        Case Else:
          MsgBox "Error encountered: " & Err.Description
          Resume Exit_Proc 'display a message then exit'
    End Function

    This should be standard for pretty much every procedure.  Tools like the invaluable mz-tools (www.mztools.com) let you customize your handler and add it to a procedure with the click of a button.

    Do a google search for VBA error handling for more info, but the above is fully sufficient.  There’s more complex global handlers that can log errors, notify developers, etc, but this is all you really need.

    Cheers


    Jack D. Leach (Access MVP)
    UtterAccess Wiki: (Articles, Functions, Classes, VB7 API Declarations and more)

    Dymeng: blog |
    Services

    • Edited by
      Jack D Leach
      Saturday, December 28, 2013 3:04 PM
      changed error number from 291 to 287
    • Marked as answer by
      Keith732
      Friday, January 3, 2014 2:11 PM

  • Your Access instance probably has the option «Breal on All Errors» selected.

    In the code window, use the Menu command Tools / Options… / General tab and chgane the error-trapping option to «Break on Unhandled Errors» and then try your code again.

    Note: the code you posted WILL display the error message when an error occurs UNLIKE Jack’s suggested code (which trap all errors and display the error message for all errors EXCEPT error 287).


    Van Dinh

    • Marked as answer by
      George Hua
      Friday, January 3, 2014 9:48 AM

Понравилась статья? Поделить с друзьями:
  • Application crashed because a fatal error occurred while checking sound bank files bannerlord
  • Application crash log generated at data nucleus coop как исправить
  • Application closed with error code 4
  • Application ce4e01 exe encountered a serious error and must shut down
  • Application caller error 2023