Error 40036 just happens

  • Thread starter Thread starter DianePDavies
  • Start date Start date
D

DianePDavies

I have an application with a subform "issueList". It works well, but
sometimes after having made changse to the code I get

Run-time error '40036'
Method'Parent' of object '_Form_issueList' failed

when running this code:

Private Sub Form_Current()
Dim rs As Object
Set rs = Me.Parent.Recordset.Clone
rs.FindFirst "[IID] = " & Me.IID
If Not rs.EOF Then Me.Parent.Bookmark = rs.Bookmark
End Sub


When I go back and recreate the changes in a backup I may very well be able
to make them without any errors. To me it look slike some bug....

Any ideas
 
There could be times when IID in the subform is null, e.g. at a new row. In
that case, your FindFirst string resolves to:
[IID] =
which is clearly going to error.

If this code goes into the *subform's* Current event, there's also a chance
of creating an endless loop here. When the subform moves record (its Current
event fires), you move the main form to a different record which will
probably re-load the subform, which triggers the subform's Current event
again and now you're in an interminable loop.

Aside from the loop problem:

Private Sub Form_Current()
Dim rs As DAO.Recordset
Dim strWhere As String

If Not IsNull(Me.IID) Then
Set rs = Me.Parent.Recordset.Clone
strWhere = "[IID] = " & Me.IID
rs.FindFirst strWhere
If Not rs.NoMatch Then
Me.Parent.Bookmark = rs.Bookmark
End If
End If
Set rs = Nothing
End Sub
 
Back
Top