• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 693
  • Last Modified:

error message .... Method Requery of object '_SubForm' failed

I have suddenly started to get an error that crashes me right out of access! ..." Method Requery of object '_SubForm' failed" .

I have an Access 2000 database (running on Access 2003 SP1) that has a form (single form view) with 2 sub forms.  

The main form Topics (based on table tblTopics fields: topicID[key], topic, etc), there is an embedded subform sfCorr (based on table tblCorr with fields: topicID, corrID[key], corr, etc) and another subform sfAction (based on tblActs - fields, ActID[key], TopicID, CorrID, Action etc)

There is one to many relationship between tblTopics and tblCorr based on field TopicID, and one to many relationship between tblCorr and tblActs based on CorrID.

The forms worked OK until I entered a lookup combo on the form to quickly find Topic. Code below...  The error comes when the combo is used to move to a new topic.

Private Sub ComboTopicFind_AfterUpdate()
    ' Find the record that matches the control.
    Dim rs As Object

    Set rs = Me.Recordset.Clone
    rs.FindFirst "[TopicID] = " & Str(Me![ComboTopicFind])
    Me.Bookmark = rs.Bookmark
End Sub

The subform sfCorr has a OnCurrent piece of code so that the subform sfAct choses the relevent records.

Private Sub Form_Current()
    Dim strParentDocName As String

    On Error Resume Next
    strParentDocName = Me.Parent.Name

    If Err <> 0 Then
        GoTo Form_Current_Exit
    Else
        On Error GoTo Form_Current_Err
        Me.Parent![sfAction].Requery
    End If

Form_Current_Exit:
    Exit Sub

Form_Current_Err:
    MsgBox Err.Description
    Resume Form_Current_Exit
End Sub

(This is the only incidence of the Requery in the whole project).  I've tried recreating combo and get no difference, have also tried repair, compact.
0
wobblynut
Asked:
wobblynut
  • 6
  • 3
  • 3
2 Solutions
 
wobblynutAuthor Commented:
Sorry a bit more,
sfCorr linked master / child fields are TopicID,  
sfAct linked fields are child CorrID;topicid    ... master sfCorr.form!CorrID;topicid
0
 
flavoCommented:
This here
>  Me.Parent![sfAction].Requery

Try

Me.Parent![sfAction].Form.Requery

or

Forms(strParentDocName).Controls(sfAction).Form.Requery

Dave
0
 
stevbeCommented:
is the comboboxon the parent or on the sub?

you could shorten that piece of code to ...

Private Sub ComboTopicFind_AfterUpdate()
    Me.Recordset.FindFirst "TopicID = " & Me.ComboTopicFind.Value
End Sub


I am curious as to why you are requerying the PArent form based on the subform ... does the parent's query use the subform control as criteria?

Steve
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
wobblynutAuthor Commented:
Sorry, more

for sfAct above read sfAction (careless me) .

The form works fine if you go to a new record using the record selectors at the bottom of the main form.
0
 
flavoCommented:
woops

Me.Parent.Controls("sfAction").Form.Requery

or

Forms(strParentDocName).Controls("sfAction").Form.Requery

Please make sure sfAction is the name of the CONTROL that holds the subform, not the subforms actual name
0
 
wobblynutAuthor Commented:
flavo
1st gives error 2455
2nd gives same error as before.

Have renamed the subform controls on the topics form to ctlCorr and ctlAction as they were the same name as the forms - no difference.  Have also changed references to those contol names in the master name for sub form and code

stevebe

Agreed, much simpler.  But didn't fix problem.
Requerying the 2nd subform not the main form.

I've now removed the error trapping in the forms and before crashing out of access get a new message
"-2147417848(80010108) Method 'Requery' of object '_subform' failed" -
0
 
stevbeCommented:
If your form/subform sets are linked with Master / Child fields you should not have to .Requery at all.
Beyond that my *guess* is that .Requery is failing because yuou have code somewhere that is suppose to set the RecordSource property of the subform and that code is either failing or not being executed in some cirumstances so .Requery does not apply ... perhaps check the .RecordSource property before the .Requery.

With Forms(strParentDocName).Controls("sfAction").Form
    If Len(.RecordSource) > 0 Then .Requery
End With


Steve
0
 
wobblynutAuthor Commented:

Have found the problem - MICROSOFT!!!!???

http://support.microsoft.com/default.aspx?scid=kb;en-us;199113&Product=acc

still doesn't give me the solution - will try to rebuild the database from scratch.
0
 
wobblynutAuthor Commented:
Have found the real problem myself - why it showed up in the way it did I don't know.  Somehow the DAO3.6 reference has been lost.  I've reinstated this and it now works fine as originally coded, have taken oportunuity to tidy up excess code.

Have awarded both of you points for your help - hope that is OK, have given Steve accepted as I liked his catching   zero length recordsource.

Thanks

Nick
0
 
wobblynutAuthor Commented:
Aaagh.
Problem has now reappeared - same error.
Time to re-build I think.  
I've had enough and am going to do something more rewarding like bashing my head with a keyboard.
0
 
flavoCommented:
maybe its corupt?

Try importing all objects into a fresh access container (mdb) first...
0
 
stevbeCommented:
I would try decompile and then import into a new database:
http://www.granite.ab.ca/access/decompile.htm
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 6
  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now