UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Run-time Error 91: Object Variable Or With Block Variable Not Set, Office 2007    
 
   
pclutts
post Apr 10 2012, 01:33 PM
Post #1

UtterAccess Veteran
Posts: 461
From: Austin, TX



Suddenly for no apparent reason to me, I am getting Run-Time Error 91 (Object Variable or With Block Variable Not Set) when I open or close the main switchboard to our project/action tracking database (an FE/BE system). The On Open event procedure for the switchboard is shown below.

Private Sub Form_Open(Cancel As Integer)

DoCmd.OpenForm "FrmInactiveShutDown", , , , , acHidden

' Minimize the database window and initialize the form.

' Move to the switchboard page that is marked as the default.
Me.Filter = "[ItemNumber] = 0 AND [Argument] = 'Default' "
Me.FilterOn = True

End Sub


When I click on Debug on the Run-Time error popup form, the system shows the following vba code which is from form frmInactiveShutDown. The line of code "If ctlNew.Name = ctlSave.Name Then" is highlighted in yellow.


Private Sub Form_Timer()
'**********************************************************************
'* This timer event procedure will shut down the application
'* after a specified number of minutes of inactivity. Inactivity
'* is measured based on how long a control remains the ActiveControl.
'**********************************************************************
Dim sngElapsedTime As Single
Dim ctlNew As Control
On Error Resume Next

Set ctlNew = Screen.ActiveControl
If Err <> 0 Then
'* No activecontrol
sngElapsedTime = Timer - sngStartTime
Else
If ctlNew.Name = "InactiveShutDownCancel" Then
'* The warning form has appeared, and the cancel button
'* is the active control
sngElapsedTime = Timer - sngStartTime
Else
If ctlNew.Name = ctlSave.Name Then
'* Still at same control
sngElapsedTime = Timer - sngStartTime
Else
'* Some change has occured, we're at a new control
Set ctlSave = ctlNew
sngStartTime = Timer
End If
If Err <> 0 Then
Set ctlSave = Screen.ActiveControl
End If
End If
End If
Err.Clear

Set ctlNew = Nothing

'Debug.Print " active control=" & ctlNew.name & " elapsed=" & sngElapsedTime

Select Case sngElapsedTime
Case Is > (intMinutesUntilShutDown * conSeconndsPerMinute)
'MsgBox "QUIT"
Set ctlSave = Nothing
DoCmd.Quit acQuitSaveAll
Case Is > ((intMinutesUntilShutDown - intMinutesWarningAppears) * conSeconndsPerMinute)
'* Make the warning form visible
Me.Visible = True
Case Else
'* The next line can be commented out if the form is opened hidden
'Me.Visible = False
End Select

Exit_Section:
End Sub


I don't have any idea where the problem is since I didn't change anything related to the switchboard or form frmInactiveShutDown. I would sincerely appreciate any help. Thanks in advance.
Go to the top of the page
 
+
Jeff B.
post Apr 10 2012, 01:36 PM
Post #2

UtterAccess VIP
Posts: 8,192
From: Pacific NorthWet



What happens if you disable that "timer" code?
Go to the top of the page
 
+
pclutts
post Apr 10 2012, 01:43 PM
Post #3

UtterAccess Veteran
Posts: 461
From: Austin, TX



I deleted the On Open and On Timer event procedures and I don't get the error message any more. However, I need the timer function.
Go to the top of the page
 
+
Bob G
post Apr 10 2012, 01:46 PM
Post #4

UtterAccess VIP
Posts: 8,193
From: CT



have you dim the ctlsave ??

you said it used to work? did you just implement Option Explicit ? You could try to compile and see if you get an error as well
Go to the top of the page
 
+
pclutts
post Apr 10 2012, 02:04 PM
Post #5

UtterAccess Veteran
Posts: 461
From: Austin, TX



I haven't dimmed the ctlsave and didn't implement Option Explicit. I'll try doing a compile with my original settings and see if that makes a difference. I'll let you know. Thanks.
Go to the top of the page
 
+
pclutts
post Apr 11 2012, 03:17 PM
Post #6

UtterAccess Veteran
Posts: 461
From: Austin, TX



Could you show me how the DIM Statement should read? Thanks again.
Go to the top of the page
 
+
Jeff B.
post Apr 11 2012, 03:50 PM
Post #7

UtterAccess VIP
Posts: 8,192
From: Pacific NorthWet



The same way you DIM'd the ctlNew...
Go to the top of the page
 
+
pclutts
post Apr 12 2012, 01:14 PM
Post #8

UtterAccess Veteran
Posts: 461
From: Austin, TX



I added "Dim ctlSave As Control" to the code but it made no difference. I still get the same Run-time error. I did a "Compact and Repair" on the database but it made no difference. I also tried compiling the database but realized I have a number of little compile errors that will take a while to fix.

I have since discovered this error is only occurring on my PC. No other users of this FE/BE system are having this problem. A person on dbForums (at http://www.dbforums.com/microsoft-access/1...rror-91-a.html) had the same problem but no solution provided. This sure is frustrating. Thanks for all the suggestions to this point.
Go to the top of the page
 
+
Jeff B.
post Apr 12 2012, 01:39 PM
Post #9

UtterAccess VIP
Posts: 8,192
From: Pacific NorthWet



It's a somewhat more involved process, but you may also wish to decompile and recompile your db.

Out of curiosity, when you describe this working on another PC, but not on yours, are you using the same (single) front-end (i.e., sharing a front-end), or are you working on your own PC's copy of the front-end? Is this db "split"? (Note: if neither "front-end" nor "split" makes sense, we need to work on something else first!)

Go to the top of the page
 
+
pclutts
post Apr 12 2012, 01:47 PM
Post #10

UtterAccess Veteran
Posts: 461
From: Austin, TX



We have a front end/back end system. I'm working on my own PC's copy of the front-end. However, I recently copied my version of the front end onto the master front end for all the others to use it and they aren't having any problems.
Go to the top of the page
 
+
Jeff B.
post Apr 12 2012, 01:53 PM
Post #11

UtterAccess VIP
Posts: 8,192
From: Pacific NorthWet



That was going to be my next suggestion ... copy something that does (or doesn't) work onto a machine where it doesn't (does) already work and test the new copy. If both the existing and copied versions work the same way, the problems with the PC, right?
Go to the top of the page
 
+
pclutts
post Apr 13 2012, 10:30 AM
Post #12

UtterAccess Veteran
Posts: 461
From: Austin, TX



I agree the problem seems to be isolated to my PC, but not sure where my investigation should go there. Next week when I have more time I plan to try creating a new front end database and copy everything over to it from the current frontend and see if that solves my problem. Thanks for the helpful discussions.
Go to the top of the page
 
+
Jeff B.
post Apr 13 2012, 10:35 AM
Post #13

UtterAccess VIP
Posts: 8,192
From: Pacific NorthWet



If you are fortunate enough (?unfortunate enough) to have a DESKTOP/PC/SUPPORT group in your organization, you may be able to push this off onto them. Something like "This app runs on every PC except one. Copying a 'working' app onto this one fails, in the same way. Copying the 'failing' on onto another PC works, the same way. Something is different about this one PC. What is it?"

Good luck!
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 19th June 2013 - 07:18 PM

Tag cloud: