Variables in report header

G

Guest

Hello,
I have a form with a tree view in it. The user can pick from among 10
choices. Once they make their choice I assign a string variable (strText)
within a case statement. The string variable may have a value of
"Parties-Appellant", "Parties Respondent", etc. Right now I am just testing
with the one value of "Parties appellant. The form opens a report and runs a
SQL select statement, part of which is the vtext value. This works fine.
It's just when I want to put the value of vtext into the report header that
it isn't working. I have an unbound text box in the header and I am using
the following function in a public module to set the value of vtext:

Public Function GetMyVar() As Variant
GetMyVar = MyVar
End Function

Then I put the following as the control source of the textbox, but when the
report runs it prompts me for a parameter value, so it's obviously not
getting the value of vtext. Thanks so much for any help.
=GetMyVar()
 
P

pietlinden

Since I just made this work with the exact syntax for the function as
you did, my guess is that it's not the function. From your error
message, it would seem that you should be passing a value into the
function and you are not doing that, at least in your example. I could
reproduce the error by trying to pass a value in the report into the
routine, though. My guess is that you'll have to grab that from
elsewhere (if that's what you're doing), because that's not visible to
the code that's trying to build the report.

This works, though... (nonsensical, but it works)

=GetMyVar([FName])

where FName is a field in the report's rowsource.


Does that help any?
 
G

Guest

Thanks so much for your help. Unfortunately I'm not using a field name but
rather a variable that's assigned once the user makes a choice from the tree
view in the form. But you helped get me on the right track and I appreciate
it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top