Problems referencing control on subform after changing source object of subform

JFHBIFF

Registered User.
Local time
Today, 15:37
Joined
Jan 8, 2006
Messages
14
Greetings everybody,

I am using an afterupdate event on my main form that changes the source object of my subform. This works fine.

If a control on that subform = true, I want to change the source object again. This is where my code fails. I get an error message stating it can't find that field. My code below.

Code:
Private Sub strIns_AfterUpdate()
Me.tblDefCatDump_subform1.Requery
Me.Command45.Visible = True
Me.Command44.Visible = True
Me.Command47.Visible = True
Me.tblDefCatDump_subform1.Visible = True
Me.Label126.Visible = True
Me.Label127.Visible = True
Me.[tblDefCatDump subform1].SourceObject = "frmInsCont1"

If Forms!frmSCOrd![tblDefCatDump subform1].Form!ysnPrefix = True Then '(Problem here)

Me.[tblDefCatDump subform1].SourceObject = "frmPrefix1"

End If

End Sub

Thanks for your help.

John
 
So is the name of the SubFormControl [tblDefCatDump subform1] or [tblDefCatDump_subform1]?
 
Thanks for offering to help RuralGuy. Somebody helped me via PM. Below is the code that worked.

Code:
Forms!frmSCOrd![tblDefCatDump subform1].Controls("ynsPrefix")

Have a great evening!
 
In which case
Forms!frmSCOrd![tblDefCatDump subform1].Form!ysnPrefix = True
...should have worked as well. Glad you got it sorted.
 

Users who are viewing this thread

Back
Top Bottom