TSCAmerica.com
TSCAmerica.com

Reputation: 5377

The expression you entered has an invalid reference to the parent property

I am getting the following error:

The expression you entered has an invalid reference to the parent property

On the following IF condition, the issue occurs on focus of a Textbox

 If Me.AB.Value <> "" And Me.Parent.Respondent = "County of ABC" And (Me.AB.Value <> GenAB) Then
 End If

Upvotes: 0

Views: 3517

Answers (1)

Big_Al_Tx
Big_Al_Tx

Reputation: 1016

A control (in this case, the textbox) has the form as it's parent, so you can reference properties of the parent (the form) when you're looking at the parent relative to the control. However, you're referring to the control from the perspective of the form --> the "Me" object, so when you refer to "Me.Parent", your asking the code to look for the parent of the form, not the textbox.

If you're looking for a control on a parent form to a subform, then it looks like your reference to "Respondent" may be the issue. Try referring to it as "Me.Parent.Respondent.Value" instead.

Also, if "Respondent" is allowed to be NULL, the if statement comparison can also fail. In those cases, I append a zero-length string to ensure the result is STRING data:

If Me.Parent.Respondent.Value & "" = "ABC" Then

Upvotes: 2

Related Questions