By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,301 Members | 3,575 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,301 IT Pros & Developers. It's quick & easy.

automation error server threw an exception

P: 11
Expand|Select|Wrap|Line Numbers
  1. For Each objObj In .CurrentProject.AllForms
  3.     DoEvents
  4.     intObj = intObj + 1
  5.     .DoCmd.OpenForm objObj.Name, acDesign, , , , acHidden
  7.     Set objForm = .Forms(objObj.Name)
  8.     With objForm
  9. 'my task
  10. end with
  11.  .DoCmd.Close acForm, objObj.Name
  12. next
  13. :errorhand
  14. Resume Next

in the above code i am getiing automation error server throw an exception this error when one of the form gets opend after that next fomrs not get accessed it throws new error
automation error the object invoked has disconnected from its clients
Oct 27 '09 #1
Share this Question
Share on Google+
5 Replies

Expert Mod 2.5K+
P: 2,545
It is hard to say what is happening without knowing the details of what MyTask is doing. The error you quote will happen if the form is closed part way through processing of objForm.

You will need to trace the exact point at which the error occurs, by setting a breakpoint at, say, the start of the FOR-loop then manually stepping through each line executed until you determine which step is causing the error.

Oct 27 '09 #2

Expert Mod 15k+
P: 31,434
When posting any code on here please :
  1. Ensure you have Option Explicit set (See Require Variable Declaration).
  2. Try to compile it. If it doesn't compile for any reason please explain that clearly - including the error message and which line of your code it appears on. Compilation is done from the Visual Basic Editor menu - Debug \ Compile Project (Where Project is the actual name of your project).
  3. Copy your code (using the Clipboard - Cut / Copy / Paste) from your project directly into your post. Typing in code is not appreciated as it is likely to introduce typos which cause members to waste their time unnecessarily.
  4. Ensure that the code in your post is enveloped within CODE tags. The hash (#) button in the posting page helps with this. Simply select your code and click on the hash button to have it enveloped automatically.
If all these points are covered then all members will be better able to understand, and therefore attempt to answer, your question.
Oct 27 '09 #3

Expert 5K+
P: 8,627
I think you need to restructure your code, something similar to:
Expand|Select|Wrap|Line Numbers
  1. Dim obj As AccessObject
  2. Dim objProject As Object
  3. Dim frm As Form
  5. Set objProject = Application.CurrentProject
  7. For Each obj In objProject.AllForms
  8.   DoCmd.OpenForm obj.Name, acDesign, , , , acHidden
  9.     Set frm = Forms(obj.Name)
  10.       With frm
  11.         'Simulate your Task(s) here
  12.         Debug.Print frm.Name & " | " & frm.Width
  13.           DoCmd.Close acForm, frm.Name
  14.       End With
  15. Next obj
Oct 27 '09 #4

P: 11
Expand|Select|Wrap|Line Numbers
  1. On Error GoTo ErrorHandler
  2. Dim appAccess As New Access.Application
  3. Dim objForm As Form
  4. With appAccess
  6. .OpenCurrentDatabase "E:\mydb\COMETV4.mdb"
  7. '.DoCmd.Minimize
  9. DoEvents
  13. Dim obj As AccessObject
  14. Dim objProject As Object
  15. Dim frm As Form
  17. Set objProject = appAccess .CurrentProject
  19. For Each obj In objProject.AllForms
  20.   DoCmd.OpenForm obj.Name, acDesign, , , , acHidden
  21.     Set frm = Forms(obj.Name)
  22.       With frm
  23.         'Simulate your Task(s) here
  24.         Debug.Print frm.Name & " | " & frm.Width
  25.          Debug.Print frm.Section(0).Height
  26.           DoCmd.Close acForm, frm.Name
  27.       End With
  28.      infrm = infrm + 1
  29.       Label1.Caption = infrm + 1
  30. Next obj
  31.     .CloseCurrentDatabase
  32. End With
  33. ErrorHandler:
  34. If Err.Number < 0 Then
  36. Label1.Caption = Err.Description
  37. End If
  38.  Resume Next
  39.  'End If
  40. End Sub
i restructured code but frm getting is nothing
Oct 28 '09 #5

Expert Mod 15k+
P: 31,434
Nikhil, in case it wasn't clear, I posted this as a moderator. That means you must pay attention and follow these instructions otherwise I will take the matter further and apply an infraction to your account.

I am trying not to slap an infraction on it quite so soon after your joining the site, but frankly I'm being swamped with issues concerning you and these must stop.

Your code wouldn't even be allowed to be entered into the code window as it is, let alone compile. This wastes the time of our experts tidying up your code which you should be doing yourself before it ever sees this forum.

You have been warned.

Oct 28 '09 #6

Post your reply

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