Link to home
Start Free TrialLog in
Avatar of edrz01
edrz01Flag for United States of America

asked on

Unable to reference a control field in a subform

I have a procedure that needs to check a control field in a subform (subfrm_Orders). The field is a Boolean yes/no in the subform for the field Select_Order.

Currently I am using:
    Dim strPurchaserEmail As Variant
    Dim strOrderSelect As String
    strPurchaserEmail = Forms!frm_CustomerOrders!eMail
    strOrderSelect = Forms!frm_CustomerOrders.subfrm_Orders.Forms!Select_Order

The first DIM is working fine in the Main form frm_CustomerOrders.

However, I am receiving the following when attempting to get the subform:
Run-time error '2465' Application-defined or object-defined error

I have tried String, Variant and Boolean

The field will be used to check if it is True to continue with the procedure to the next step.
Avatar of Gustav Brock
Gustav Brock
Flag of Denmark image

Make sure you use the name of the subform control, not the name of the form, and property Form, not Forms:

    strOrderSelect = Me!NameOfSubformControl.Form!Select_Order

/gustav
Avatar of edrz01

ASKER

I have set      strOrderSelect = Me!subfrm_Orders.Form!Select_Order and receive the error message: can't find the field 'subfrm_Orders' referred to in your expression.

--subfrm_Orders is the name of the subform.
Avatar of Arana (G.P.)
Arana (G.P.)

strOrderSelect = Forms!frm_CustomerOrders.form!subfrm_Orders.Form!Select_Order

like this:
Me!Subform1.Form!Subform2.Form!ControlName
Then 'subfrm_Orders' isn't the name of the control.
Avatar of edrz01

ASKER

The field I am attempting to check is Select_Order which is in the Sub Form... subfrm_Orders circled in Red

User generated image
have you tried my suggestion?
ASKER CERTIFIED SOLUTION
Avatar of PatHartman
PatHartman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of edrz01

ASKER

Arana, Gustav and Pat....
Thank you for your direction. I guess I did not fully understand the Control Source and mistook the Sub Form name as the Control. Which it isn't.

Pat, your first sentence opened my eyes that I was looking at the incorrect naming and concentrated on the name "subfrm_Orders" which is the Source Object and not the Control Name "Orders". I'm glad to have added the Property image to clear this up.

I used:
strOrderSelect = Me!Orders.Form!Select_Order

Arana - your post "Subform1.Form!Subform2.Form!" I did not fully understand the use of two Subform1 and Subform2
Gustav - your post "'subfrm_Orders' isn't the name of the control. " had me trying to figure out what the name was...

So, that's that. I'd like to give you all credit for pointing me in the right direction.

User generated image