Method 'Form' of object '_SubForm' failed

kbrown

Registered User.
Local time
Yesterday, 18:31
Joined
Dec 4, 2003
Messages
45
I am getting this error message "Method 'Form' of object '_SubForm' failed", when my code On Current runs (see code below), when I click on cmdGrowth (which opens another form-Growth) and when I click on the close button for the Growth form. Prior to today this functioned fine. I was making some coding changes today, but not anything having to do with this section of code or the cmdGrowth button (at least as far as I am aware-I got kind of deep into it, so I am not able to completely retrace my tracks). I cannot find reference to this error message anywhere. Can someone please help me make sense of the error message and maybe look at my code to see if there is something there that I am missing? Is it possible my Growth form got corrupted somehow in what I was doing? Any ideas would be appreciated!

Thank you,
Kristen

Private Sub Form_Current()
On Error GoTo Form_Current_Err

'When ClientInfo is not a new record, run the following code
If Me.NewRecord = False Then
' Synchs FindName and current record

Forms!frmClientInfo!cboFindName = Forms!frmClientInfo!ClientID

'If Program = Pregnant Woman, cmdGrowth.enable = false
'and DueDate.visible = true

If Me!frmEnrollment.Form!Program = "Pregnant Woman" Then
Me!cmdGrowth.Enabled = False
Me!DueDate.Visible = True

'Otherwise cmdGrowth.enable = true and DueDate.visible = false

Else
Me!cmdGrowth.Enabled = True
Me!DueDate.Visible = False
End If

End If

Form_Current_Exit:
Exit Sub

Form_Current_Err:
MsgBox Error$
Resume Form_Current_Exit

End Sub
 
I don't see any coding problems having to do with subforms in that code. What about the code in the click event of the cmdGrowth button and the close button of the Growth form you mentioned?
 
I had a little time this morning to poke around some more and it seems like the message occurs when a code refers to my frmEnrollment subform. I don't know if it makes any difference, but these were originally macros that I converted to VBE and am in the process of making more streamlined. I did try to recreate the VBE code directly and still had the same problem. Here is another procedure that creates the error message. There are a couple of other places that are showing the same thing, but I didn't want to overload anyone with the code. Does anyone know how to interpret the error message? I don't really know what it is trying to say. Thanks

frmGrowth-on Current:
Private Sub Form_Current()
On Error GoTo Form_Current_Err

If (Forms!frmClientInfo!frmEnrollment.Form!Program = _
"Early Head Start") Then
' If Program=EHS Set BMI Visible No
Me!BMI.Visible = False
' If Program=EHS Set BMI_Label Visible No
Me!BMI_Label.Visible = False
End If

Form_Current_Exit:
Exit Sub

Form_Current_Err:
MsgBox Error$
Resume Form_Current_Exit

End Sub
 
This is the only expression I can see that is referring to a subform:
Forms!frmClientInfo!frmEnrollment.Form!Program

Are you sure you've got the proper names in that line? frmEnrollment is the subform on the frmClientInfo main form?
 
Yes, those are the names and I have double and triple checked, even though I know I didn't change them just to make sure. In searching for more info, it looks like maybe the problem has to do with a reference library. But I can't make heads or tails of that because everything that has been checked is still checked. I'm wondering if it's a bug of some kind. Our IT person is looking in to that and maybe there's a VB patch we can download. So far, the only other post here that I found that is exactly the same error message died out without any answer being provided. I can always go back to a previous edition of the database, but I hate to let this question go unanswered!

Thanks,
Kristen
 
My IT person found this solution somewhere on the internet:

"I just went through the same thing. What I found was that the "Method 'Form' of Object '_Subform' failed" error was caused by a corrupt subform.

To resolve:
- create a new form
- copy/paste the controls from the subform that's giving you trouble
- update the properties of the new subform to match the old subform
- juggle the names of the new/old subforms"

This solved my problem....for now.

Kristen
 

Users who are viewing this thread

Back
Top Bottom