Runtime-Error 9, when other user has source sheet open

  • I have an 'intake form' sheet that gets its data from the database, which in turn gets some of its data from excel sheets (three to be exact - but lets just use one for this purpose, called 'Ad hoc request').


    Here is the intake form where all data is to deposit - the debug shows the error (in red):


    [vb]Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    Cancel = True
    End Sub


    Private Sub Worksheet_Change(ByVal Target As Range)
    Application.ScreenUpdating = False
    If Sheets("INTAKE").Range("A1").Value = Sheets("Data").Range("A2").Value Then Exit Sub
    If Not Intersect(Target, Me.Range("A1")) Is Nothing Then NOImportVehicle
    Call update
    Sheets("INTAKE").Select
    Application.ScreenUpdating = True
    End Sub


    Private Sub update()
    Dim r As Range, c As Range
    Dim MyPassword As String
    MyPassword = ""
    Application.ScreenUpdating = False
    Sheets("INTAKE").Select
    With Sheets("INTAKE")
    .Unprotect Password:=MyPassword
    End With
    DoEvents
    Set r = Range("A1:A299")
    For Each c In r
    If Len(c.Text) = 0 Then
    c.EntireRow.Hidden = True
    Else
    c.EntireRow.Hidden = False
    End If
    Next c
    DoEvents
    With Sheets("INTAKE")
    .Protect Password:=MyPassword
    End With
    Sheets("INTAKE").Select
    Application.ScreenUpdating = True
    End Sub[/vb]


    The spelling is correct. The code runs fine when nobody else is in the source data 'Ad hoc request' excel sheet. If I'm in it, it works because I'm the admin of that sheet at that time. But if anyone has the ad hoc sheet open, it won't deposit the data into the database and therefore my intake form - in return, I get the error. How can I circumvent the admin rights and just deposit the latest saved information from the ad hoc request sheet into the database, and intake form?


    The ad hoc sheet has no VBA attached to it. It is simply used as a data entry form, from which the database gets its source data.


    Thanks for your help in advance! (pretty new to this)

  • Re: Runtime-Error 9, when other user has source sheet open


    I think I've decided to push the data on close to a new master worksheet and have the database extract its info from that instead of the data entry form.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!