Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Complex String Concatenation in a Report 1

Status
Not open for further replies.

Genimuse

Programmer
May 15, 2003
1,797
US
Sorry, I'm sure this is an idiotic question, but I've searched the archives, Access help, etc. and can't seem to figure this simple-seeming thing out.

I've got a report where some of the text is a combination of several fields and spaces and symbols and such, with plenty of conditions.

In the report I can't seem to reference an unbound textbox and set it to something (this would solve my problem), and I can't seem to reference more than one hidden form field (because of focus reference problems), so I've resorted to global variables. I created a new module that looks like this:
Code:
Option Compare Database

Global Summary1 As String
Global Summary2 As String
It appears that I'm referencing them ok in my form code (setting them to the complex concatenated strings) but I can't seem to reference them in the report -- if I set a textbox's data to "=[Summary1]" it asks for it when I open the report.

Whew. So... How can I reference globals? Or how can I set the value of a textbox on a form to something in code (like in the Open event)? Or how can I reference multiple unbound hidden form fields? Lame questions, I know, but I just can't quite seem to understand these basic referencing issues.
 
Sorry, I am unclear as to how you are attempting to reference things from your report. But I believe you are going to have to create the report's recordsource (including all of the concatenations) in code and then pass it complete to the report.

Cheers
Bill
 
My preferred method for referencing Global variables in a report is write a wrapper function in a standard code module.

The control source would be
=GetSummary()

and the function would be as follows:

Public Function GetSummary As String
GetSummary = Summary1
End Function

and of course, for more complex concatenations, you can handle them inside the function.

Public Function GetSummary () As String
GetSummary = Summary1 & " - " & Summary2
End Function

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Perfect, that's exactly what I was looking for, thanks!

PS: Why doesn't the report see the global variable on its own?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top