Problem with sub sourceobject

opopanax666

Registered User.
Local time
, 23:41
Joined
Nov 2, 2006
Messages
44
Hi everyone,

I have a main, a subform and a optiongroup on the subform. The subform-container is called "SubFrm", and is initially loaded with "frmTransportmiddel". When a button in the optiongroup is pressed, the container needs to load another form ("frmProductgroep").

The code:
Code:
Private Sub optgrpRollend_AfterUpdate()

    If Me.optgrpRollend.Value = 16 Then
        DoCmd.OpenForm "frmAantalMK"
    Else
        TRol = DLookup("Transport_gewicht", "qryTransport_middelen_soort", "Soort_ID = " & Me.optgrpRollend.Value)
        sngTarra = sngTarra + TRol
        Me.Parent.txtMainTarra.Value = sngTarra
        Me!SubFrm.Form.SourceObject = "frmProductgroep"

    End If

End Sub

When I press a button in the optiongroup, I get an error 2465 "can't find field SubFrm". When I use the exact same syntax with a button on the main, it works. So I guess it's a reference problem...
I thought that maybe it was a "focus" problem, but even when I change the code to focus a control on the main before changing sourceobject, it doesn't work either...

Any feedback would be appreciated!
 
If the code is being run from the subform then I think this:

Code:
Me!SubFrm.Form.SourceObject = "frmProductgroep"


Needs to be this:

Code:
Me.Parent.SubFrm.SourceObject = "frmProductgroep"

hth
Chris
 
Absolutely right... Thanks!
 

Users who are viewing this thread

Back
Top Bottom