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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Executing parent function from subform 2

Status
Not open for further replies.

damo317

Technical User
Jun 30, 2003
9
NZ
How can I execute a function from the Parent module of a subform?
What I want to do is set the 'On_dirty' event of the subform to run a function within the parent.
I tried
Forms!frmStudents.Form_Open (0)
and
Me.Parent.Form_Open(0)

but they both give: Runtime error 2471 - 'The object doesn't contain the Automation object id'

I changed the Form_Open scope to Public but it made no difference.

damo317
 
Show your code. What function are you trying to 'run?'

rollie@bwsys.net
 
in Form: frmFollowUp
Public Sub Form_Open(Cancel As Integer)
Me!histCount = DLookup("Count(*)", "tblFollowUp", "[student_id] = id")
Me!histCompletedCount = DLookup("Count(*)", "tblFollowUp", "[student_id] = id and [completed] = true")

newFUdate.Enabled = Not IsNull(id)
newFUnotes.Enabled = Not IsNull(id)
AddnewFU.Enabled = Not IsNull(id)
End Sub

in Form: frmFollowUp subform
Private Sub Form_Dirty(Cancel As Integer)
Me.Parent.Form_Open (0)
End Sub

So, when the subform is dirty it is supposed to execute/run/jmp/whatever the function 'Form_Open' that is contained in the module of the forms parent
 
To make sure the sf is dirty, put a msgbox there and see where the problem is. Also use the msgbox to see if it is ever getting to the me.parent form. I would ask (with msgbox) the name of the parent to be sure where you are.

rollie@bwsys.net
 
Aha thankyou!

I had just assumed that it was a problem with the way i was calling the function, and never thought it was actually getting inside the function it was calling. The problem was that i was referencing 'id' in the DLookup functions and the subform didn't know what id was. Changing id to Me.id fixed it.

Cheers
dave
 
If these 'tips' are helpful, click on the "Mark this post helpful..." Us "kindergarten kids' work for stars you know.

rollie@bwsys.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top