0

In my report why is it that when I set the ControlSource on a textbox in a report to a field name like this: txtSomeTextBox.ControlSource = [Expr1] it populates as expected but when I define a user defined function like this:

Public Function GetString(strValues As String) As String
GetString = "Values: " & strValues
End Function

Then set the ControlSource property to txtSomeTextBox.ControlSource = GetString([Expr1]) it doesn't know what to do! In fact the textbox displays: "#Type!" Why can't I pass the value of [Expr1] to the function?

1 Answer 1

1

You need a = to evaluate a function.

=GetString([Expr1]) as controlsource works for me.

Sign up to request clarification or add additional context in comments.

4 Comments

I'm thinking that [Expr1] is not a String but some other data type?
@Alan: Then try Public Function GetString(varValues As Variant) As String
Tried it. I get run time error: You entered an expression that has no value.
I found the problem. The name of the textbox had a circurlar reference to itself. Its name was the same as the field name. I renamed the textbox to txtAllValues and that fix it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.