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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Concatonating Several text boxes

Status
Not open for further replies.

pcmaps

Technical User
Jun 29, 2008
3
US
I'm trying to a report to form test questions about a group of titles. The titles must be underlined, and must be followed by a comma, which is not to be underlined. My outcome will be "in the book xxxx(underlined), what is..." Title is a field. If I concat title with comma, everything is underlined. If I do not concatonate title with comma, then I have a huge gap between the end of the title field and the fixed comma:
"in the book Shiloh ,what is". I think what I need is to get the width of the textbox to dynamically match the length of my title, but I don't know how to do it. Any thoughts would be greatly appreciated.
 
You can make the text boxes invisible and then "print" them with code in the On Format event of the section. The following code prints

Subject: New sub-agreement John Smith under the...

Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    Me.FontSize = 12
    Me.CurrentX = Me.ContactName.Left
    Me.CurrentY = Me.ContactName.Top
    Me.Print "Subject: New sub-agreement "
    Me.FontUnderline = True
    Me.CurrentY = Me.ContactName.Top
    Me.FontBold = True
    Me.Print Me.ContactName
    Me.FontUnderline = False
    Me.FontBold = False
    Me.CurrentY = Me.ContactName.Top
    Me.Print " under the..."
End Sub

Duane
Hook'D on Access
MS Access MVP
 
Duane, thank you for the quick reply. By your John Smith example, I can tell that you understand exactly what I must do, but I am not able to reproduce your results.

If I copy your code to an on format event of a report's detail section, then my visible report is repeated grayed out rectangle - no text printed at all. I tried making an invisible text box bound to field title, and substituted "title" for your contactname.

Also tried it without all that! :~D
I'm using Access 2007 - but the db is 97-2003 format. I truly appreciate your help.
 
I haven't tried this with 2007. Could you share the code that you tried? I don't understand what you mean by "my visible report is repeated grayed out rectangle".

Duane
Hook'D on Access
MS Access MVP
 
Oh my goodness, of course it works - in print preview! The grayed box shows up in report view. You are brillant! May I try your patience with one more question - how to handle line wrap using your method?

My question field can be quite lengthy: - (I'm printing introductory phrase, title, comma/space, question; title and question are both fields) it's being truncated when the text runs to the right edge of the report. I need the question to continue on the next line until it is all fully visible.

I've tried changing the invisble title field to "can grow", but no luck. Thank you!
 
The Print method will not word wrap. You will need to use Mid(), instr(), left(), etc to find a space for the break based on estimated number of characters that fit on one line. The first line would be printed with the above solution and the remainder of the quesion would be displayed using a bound text box.

In 2007, you may be able to use a rich text control but I am not experienced with this.

Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top