Results 1 to 5 of 5

Thread: Error 91

  1. #1
    Join Date
    Aug 2006
    Posts
    559

    Unanswered: Error 91

    Ok, so anyone want to try to explain why I get the following ONLY on my machine with the DB installed? When I do an install on any other machine, it works fine with no errors. I've tried to repair MS Office on my machine 3x and it doesn't help...

    Error is:

    "Run-time error '91': Object variable or With block variable not set"

    Clicking 'debug' gives you this, with the area in BOLD highlighted:

    Code:
    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
    Dim i As Integer
    On Error Resume Next
    
    Set ctlNew = Screen.ActiveControl
    If Err <> 0 Then
        '* No activecontrol
        sngElapsedTime = Timer - sngStartTime
        Err.Clear
    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

  2. #2
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    What happens if you add: Dim ctlSave as Control somewhere in a line above or in the beginning of the code. Not sure why it errors only on your machine but perhaps adding the Dim statement might fix it (maybe it only hits the "If ctlNew.Name = ctlSave.Name Then" on your machine.) I'd perhaps add a msgbox to see if it also hits that code on the other machines or see if a Dim ctlSave as Control is found elsewhere. I'm guessing the error is related to this though.


    Also maybe a msgbox Screen.ActiveControl somewhere.
    Last edited by pkstormy; 01-18-08 at 17:40.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  3. #3
    Join Date
    Aug 2006
    Posts
    559
    Quote Originally Posted by pkstormy
    What happens if you add: Dim ctlSave as Control somewhere in a line above or in the beginning of the code. Not sure why it errors only on your machine but perhaps adding the Dim statement might fix it (maybe it only hits the "If ctlNew.Name = ctlSave.Name Then" on your machine.) I'd perhaps add a msgbox to see if it also hits that code on the other machines or see if a Dim ctlSave as Control is found elsewhere. I'm guessing the error is related to this though.


    Also maybe a msgbox Screen.ActiveControl somewhere.

    I'll try it Paul. Thanks. I know it has to do with the "Autologout" feature of the DB. But I've opened the DB on another machine and it doesn't happen so figure it's my main machine. But I'll try it and see what happens.

  4. #4
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Psst.......... What happens when there's no old (or new) active control?
    George
    Home | Blog

  5. #5
    Join Date
    Apr 2003
    Location
    Austin, TX
    Posts
    21
    Did you ever find a solution to your problem. I'm having the exact same problem myself. Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •