Error 40036 just happens

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
 
A

Allen Browne

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top