Link to home
Start Free TrialLog in
Avatar of wobblynut
wobblynut

asked on

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.
Avatar of wobblynut
wobblynut

ASKER

Sorry a bit more,
sfCorr linked master / child fields are TopicID,  
sfAct linked fields are child CorrID;topicid    ... master sfCorr.form!CorrID;topicid
This here
>  Me.Parent![sfAction].Requery

Try

Me.Parent![sfAction].Form.Requery

or

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

Dave
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
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.
SOLUTION
Avatar of flavo
flavo
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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" -
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

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.
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
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.
maybe its corupt?

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