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

Problem Building Strings: Is the following possible?

Status
Not open for further replies.

socomfort

Technical User
Jul 8, 2005
46
US
I am trying to build a string based upon a recordset by concatenating the fields as follows:

Code:
Private Sub ReportFooter_Format(Cancel As Integer, FormatCount As Integer

Dim db1 As dao.Database, rs1 As dao.Recordset, myString As String, strTxtAttach as String

Set db1 = CurrentDb

myString = "SELECT Field1, Field2, Field3,...WHERE [condition]

Set rs1 = db1.OpenRecordset(sql, dbOpenDynaset, dbSeeChanges)

strTxtAttach = ""

If rs1.Fields("chkBox1") = True Then
strTxtAttach = strTxtAttach & "Per " & Me.Field1 & " Identification Number: " & " " & rs1.Fields("Field2") &   vbCrLf & vbCrLf
End If

strTxtAttach = strTxtAttach & Me.FontUnderline("This is the section text to format:")...

Me.txtSection1 = strTxtAttach

I'd like to know if it is possible to format text while building a string of values. What I am trying to do is to populate a large text box on a report in one shot.

If I can, I'd like to separate the lines of text with vbCrLf but for section headers like the one above, I'd like to change the look by underlining, making bold and changing the font size.

I know that I can use Space(n) to indent or I can also manipulate position by using a scale based upon number of twips. But, I am not sure that I can do what I mention above. Any suggestions are most appreciated.

thanks,

Ben
 
It may be possible with a Rich Textbox, but I have not tried it properly.

Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Me.ActiveXCtl0.Value = "{{\b bold }{\ul underline}}"
End Sub
 
And possibly, outside of the formatting,
using the control source of the textBox

=IIF(chkBox1,[txtCountry] & "Hello",[txtEmail] & ";" & [txtCity])

...for example.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top