Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Method 'Requery' of object '_subform' failed

Status
Not open for further replies.

swaybright

Technical User
Jun 25, 2003
156
US
Hi all,

Method 'Requery' of object '_subform' failed

I'm getting the above error message when I click the record navigation button to go to the first record on a form.
My form has 4 subforms. The first subform (ResinData) dictates the data viewed in the other three. I have a requery set to the OnCurrent event of the ResinData subform to update the data in other 3 subforms.
My code is:
Sub Form_Current()

Dim ParentDocName As String

On Error Resume Next
ParentDocName = Me.Parent.Name

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

Form_Current_Exit:
Exit Sub

Form_Current_Err:
MsgBox Error$
Resume Form_Current_Exit

End Sub

I also have code on the oncurrent event of the main form that enables/disables some subform fields based on an option group it is:

Private Sub Form_Current()
Select Case CompoundSelect
Case 1
Forms(&quot;TSR&quot;)(&quot;ResinData&quot;).Form.Controls(&quot;CPResearchID&quot;).Enabled = False
Forms(&quot;TSR&quot;)(&quot;LevelData&quot;).Form.Controls(&quot;Level2&quot;).Enabled = False
Forms(&quot;TSR&quot;)(&quot;Molecule2&quot;).Form.Visible = False
Case 2
Forms(&quot;TSR&quot;)(&quot;ResinData&quot;).Form.Controls(&quot;CPResearchID&quot;).Enabled = True
Forms(&quot;TSR&quot;)(&quot;LevelData&quot;).Form.Controls(&quot;Level2&quot;).Enabled = True
Forms(&quot;TSR&quot;)(&quot;Molecule2&quot;).Form.Visible = True
End Select
If TSRNo = &quot;&quot; Then
Me.AllowEdits = True
Else
Me.AllowEdits = False
End If

End Sub


Everything works fine in terms of scrolling from record to record. I only get the error when I try to jump to the first record. After the error pops up, Access locks up.
This is really annoying. I know I can remove the navigation buttons, but that would be inconvienent to the user.

Does anyone have any IDEAS???

Shane
 
Hi swaybright,

I would replace ALL the first subform (ResinData) with just:

Sub Form_Current()
On Error Resume Next
Me.Parent!LevelData.Requery
Me.Parent!Molecule.Requery
Me.Parent!Molecule2.Requery
End Sub

1. There's no need for an error procedure, probably the error procedure is causing the error.

2. ParentDocName seems to have no purpose. ie You're declaring it but not using it for anything.

Bill


 
Bill,

You're right, I saw no purpose for the declared variable, but I was building off of code generated by Access form wizard.

I have replaced the code, but there still is a problem. It seems like, when I click the goto first record navigation button, the on current event is run over and over and over and over . . .
I removed the on error clause from your code, but it still happens.
Any thoughts?

Shane
 
Hi Shane,

You are welcome to send me a copy of your DB removing any sensitive records first. Will post any suggestions here in this thread later.

Bill

billpower@cwcom.net
 
Re-creating the subform (create a new form in design view, copy and paste all the controls from the old subform, set the properties, juggle the names) should resolve the method-of-subform-failed error.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top