Question about the Runtime Error 429

magster06

Registered User.
Local time
Today, 18:51
Joined
Sep 22, 2012
Messages
235
Hello All,

I have a quesiton:

I have in place an error handler that traps the Runtime error 429 and resumes with the rest of the code; by trapping the error , will it overtime corrupt my database?

Thanks!
 
Does your database still function as you designed it even though you get this error 429?

Only you can tell if the error is relevant. We don't know anything about your database and you have only told us you get an error.

Try google "msaccess error 429" for some suggestions/links.
 
I concur with jdraw. We have no context with which to answer the question.

Run-time error '429': ActiveX component can't create object.

What object are you trying to create? Whatever it is, I don't know why failing to create it would corrupt the database. Regardless, it never hurts to run a Compact and Repair on a regular basis, and may be even have it run automatically, either on exit or by a VBA process.
 
Sorry for the general question.

It is with the code to generate a word from from access.

Code:
Private Sub cmdPrintCCUForm_Click()
    Dim appWord As Word.Application
    Dim doc As Word.Document
 
    On Error GoTo errHandler
 
    'Set appWord object variable to running instance of Word.
    Set appWord = GetObject(, "Word.Application")
    'Set appWord = CreateObject("word.Application")
    If Err.Number <> 0 Then
        'If Word isn't open, create a new instance of Word.
        Set appWord = New Word.Application
 
    End If
 
    Set doc = appWord.Documents.Open("C:\Users\arrudad\Documents\AutoForms\CCUform.docx", , True)
        With doc
            .FormFields("fldRank").Result = Nz(Me![Rank])
            .FormFields("fldFocus").Result = Nz(Me![Focus First Name] & "" & " " & "" & [Focus Last Name])
            .FormFields("fldFDID").Result = Nz(Me![Focus FDID])
            .FormFields("fldBattAssignUnit").Result = Nz(Me![Battalion] & "/" & " " & [Focus Assignment] & "/" & " " & [Focus Unit])
            .FormFields("fldInvestigator").Result = Nz(Me![Case Investigator])
            .FormFields("fldCaseNumber").Result = Nz(Me![CaseNumber])
            .Activate
        End With
 
 
 
    Set doc = Nothing
    Set appWord = Nothing
    Exit Sub
errHandler:
If Err.Number = 429 Then
    Resume Next
Else
    MsgBox Err.Number & ": " & Err.Description
End If
End Sub

The code works trapping the 429 error, but I didnt know if over time that the db would become corrupt.

If I remove the
Code:
 Set appWord = GetObject(, "Word.Application")
part and replaced it with
Code:
'Set appWord = CreateObject("word.Application")
but get "object not set"

I read where
Code:
Set appWord = New Word.Application
should not be used as this could create the 429 error.

Not sure what to use in its place

Code:
Set doc = appWord.Documents.Add
?


What object are you trying to create? Whatever it is, I don't know why failing to create it would corrupt the database. Regardless, it never hurts to run a Compact and Repair on a regular basis, and may be even have it run automatically, either on exit or by a VBA process.

Yes, that is what I was thinking, but was not 100% sure. Yes, I have the db to "Compact and Repair" on exit.
 
I have used this to see if a particular exe is running

Code:
'---------------------------------------------------------------------------------------
' Procedure : IsExeRunning
' Author    :  James Barash(AccessD)
' Created   : 3/17/2009
' Purpose   : To determine if a specific program is currently running.
'---------------------------------------------------------------------------------------
' Last Modified:
'
' Inputs:  The name of the program
' Dependency: N/A
'------------------------------------------------------------------------------
'
Public Function IsExeRunning(strExeName As String) As Boolean
Dim objProcesses As Object, objProcess As Object
  IsExeRunning = False
  Set objProcesses = GetObject("winmgmts://" & Environ$("ComputerName") _
 & "/root/cimv2").ExecQuery("select * from Win32_Process")
  If Not objProcesses Is Nothing Then
    For Each objProcess In objProcesses
      If objProcess.name = strExeName Then
          IsExeRunning = True
          Exit For
      End If
    Next
    Set objProcess = Nothing
    Set objProcesses = Nothing
  End If
End Function


You could check and see if WORD.EXE is running

if it is then just use GetObject

if it isn't running then use the Createobject


Here's a sample that you can fit into your code

Code:
If IsEXERunning("WORD.EXE")  Then
   Set appWord = GetObject(, "Word.Application")
else
  Set appWord = CreateObject("word.Application")
end if
 
jdraw,

I get an error message "Ambiguous name detected: IsExeRunning"

Also, I am suppose to place my computer name in the function

***UPDATE***

Scratch the Ambiguous part, I copied and pasted your code with the Public Function part.


***Another UPDATE***

-214217375 Automation Error
 
Last edited:
No. I may have assumed too much.
Do you use modules and vba at all?

You would need to


1. put the Function code (the one at the top of the post I sent earlier) into a Module in your database, and save it. Then

2.test to see if the IsEXERunning is working,

paste this code into your Module
Code:
'---------------------------------------------------------------------------------------
' Procedure : jtestit
' Author    : Jack
' Created   : 3/17/2009
' Purpose   : Test routine to ensure IsEXERunning function is working
'---------------------------------------------------------------------------------------
' Last Modified:
'
' Inputs: N/A
' Dependency: N/A
'------------------------------------------------------------------------------
'
Sub jtestit()
Dim smyEXE As String

smyEXE = "msaccess.exe"
Debug.Print "Is " & smyEXE & " running: " & IsExeRunning(smyEXE)
End Sub

You should see a print out in the immediate window.
When this is working then move to 3.


3. Adjust your code the Private Sub cmdPrintCCUForm_Click()...... code
to use the If statement I suggested.

I think this should do it. (you should be able to copy and paste this code).
I suggest you copy your existing code and save it as text somewhere.
Then paste this code into your application.

Code:
'------------------------------------------------------------------------------------
' Procedure : cmdPrintCCUForm_Click
' Author    : JDraw
' Date      : 04-04-2013
' Purpose   : Added the IsExeRunning function to test if WORD is runninig
'              If Word Is Running then use it (getObject)
'              If Word Is Not Running then create it (CreateObject)
'---------------------------------------------------------------------------------------
' Last Modified:
'
' Inputs: N/A
' Dependency: N/A
'--------------------------------------------------------------------------
'
Private Sub cmdPrintCCUForm_Click()
    Dim appWord As Word.Application
    Dim doc As Word.Document
 
    On Error GoTo errHandler
 '****    original code
 'This code has been commented
    ''Set appWord object variable to running instance of Word.
   ' Set appWord = GetObject(, "Word.Application")
    'Set appWord = CreateObject("word.Application")
  
 '   If Err.number <> 0 Then
 '       'If Word isn't open, create a new instance of Word.
 '       Set appWord = New Word.Application
 '
 '   End If
  '**** end original code
  
  '************ code jdraw **************
  '
  'This new code to test if Word is Running
  '
     If IsExeRunning("WORD.EXE") Then
         Set appWord = GetObject(, "Word.Application")
     Else
         Set appWord = CreateObject("word.Application")
     End If
  '
  ' ***** end of code  jdraw
 
    Set doc = appWord.Documents.Open("C:\Users\arrudad\Documents\AutoForms\CCUform.docx", , True)
        With doc
            .FormFields("fldRank").result = Nz(Me![Rank])
            .FormFields("fldFocus").result = Nz(Me![Focus First Name] & "" & " " & "" & [Focus Last Name])
            .FormFields("fldFDID").result = Nz(Me![Focus FDID])
            .FormFields("fldBattAssignUnit").result = Nz(Me![Battalion] & "/" & " " & [Focus Assignment] & "/" & " " & [Focus Unit])
            .FormFields("fldInvestigator").result = Nz(Me![Case Investigator])
            .FormFields("fldCaseNumber").result = Nz(Me![CaseNumber])
            .Activate
        End With
 
 
 
    Set doc = Nothing
    Set appWord = Nothing
    Exit Sub
errHandler:
If Err.number = 429 Then
    Resume Next
Else
    MsgBox Err.number & ": " & Err.Description
End If
End Sub
 
Last edited:
jdraw,

I'll try it when I get back into work in the morning. I appreciate the help.
 
Sorry for the general question.

It is with the code to generate a word from from access.

Code:
Private Sub cmdPrintCCUForm_Click()
    Dim appWord As Word.Application
    Dim doc As Word.Document
 
    On Error GoTo errHandler
 
    'Set appWord object variable to running instance of Word.
    Set appWord = GetObject(, "Word.Application")
    'Set appWord = CreateObject("Word.Application")
    If Err.Number <> 0 Then
        'If Word isn't open, create a new instance of Word.
        Set appWord = New Word.Application
 
    End If
 
    Set doc = appWord.Documents.Open("C:\Users\arrudad\Documents\AutoForms\CCUform.docx", , True)
        With doc
            .FormFields("fldRank").Result = Nz(Me![Rank])
            .FormFields("fldFocus").Result = Nz(Me![Focus First Name] & "" & " " & "" & [Focus Last Name])
            .FormFields("fldFDID").Result = Nz(Me![Focus FDID])
            .FormFields("fldBattAssignUnit").Result = Nz(Me![Battalion] & "/" & " " & [Focus Assignment] & "/" & " " & [Focus Unit])
            .FormFields("fldInvestigator").Result = Nz(Me![Case Investigator])
            .FormFields("fldCaseNumber").Result = Nz(Me![CaseNumber])
            .Activate
        End With
 
 
 
    Set doc = Nothing
    Set appWord = Nothing
    Exit Sub
errHandler:
If Err.Number = 429 Then
    Resume Next
Else
    MsgBox Err.Number & ": " & Err.Description
End If
End Sub

The code works trapping the 429 error, but I didnt know if over time that the db would become corrupt.

If I remove the
Code:
 Set appWord = GetObject(, "Word.Application")
part and replaced it with
Code:
'Set appWord = CreateObject("word.Application")
but get "object not set"

I read where
Code:
Set appWord = New Word.Application
should not be used as this could create the 429 error.

Not sure what to use in its place

Code:
Set doc = appWord.Documents.Add
?


Yes, that is what I was thinking, but was not 100% sure. Yes, I have the db to "Compact and Repair" on exit.

Hi magster,
you have a slight problem with the code above. You started with the right idea but then went astray.

The start of the Sub should look like this

Code:
Private Sub cmdPrintCCUForm_Click()
Dim appWord As Word.Application
Dim doc As Word.Document
 
On Error [B]Resume Next[/B]
'Set appWord object variable to running instance of Word.
Set appWord = GetObject(, "Word.Application")
If Err.Number <> 0 Then
'If Word isn't open, create a new instance of Word.
 
Set appWord = CreateObject("word.Application")
Err.Clear
End If

This is the standard way of creating the Word object if no instance of Word is available. You do not need anything else to determine if Word is running. The error (of not getting the nonexistent object) is trapped and handled. After this If block, you may set the On Error to go to you your error handler.

Best,
Jiri
 
jdraw,

I get an automation error and it highlights this section:

Code:
Set objProcesses = GetObject("winmgmts://" & Environ$("GB03300400005") _
 & "/root/cimv2").ExecQuery("SELECT * from Win32_Process")
Maybe something to do with the computer name? this is a network computer that I am on.

Jiri,

This is the standard way of creating the Word object if no instance of Word is available. You do not need anything else to determine if Word is running. The error (of not getting the nonexistent object) is trapped and handled. After this If block, you may set the On Error to go to you your error handler.

I originally had this code setup the way you described with the exception of another errror handling. I did not realize that I could use 2 seperate error handlers in a code block.

Thanks for the reply and assistance.
 
Jiri,

I originally had this code setup the way you described with the exception of another errror handling. I did not realize that I could use 2 seperate error handlers in a code block.

Thanks for the reply and assistance.

You are welcome. It's the "On Error Go To...." line that caused you the trouble. If you just resume on the next line trapping the non-zero Err.Number (and clearing it), you are ok. And yes, you can change the error handling in a block as many times as you want.

Best,
Jiri
 
magster06,

Yes Jiri's solution is the way to go. I had been going thru some stuff recently and saw that routine to see what exe's were running. It came to mind as a way to deal with WORD, but the general approach, as was said, is


try to GetObject for an existing copy of the application
if you get a non-zero response then
the application isn't running, so do a CreateObject

Good luck.
 

Users who are viewing this thread

Back
Top Bottom