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

Can this be done in a Report?

Status
Not open for further replies.

Sullaway

Technical User
Sep 27, 2000
50
US
I would like to combine several fields into one field on my report, ie Address,City,State,Zip Code but I would like it to look like...

Address
City
State
Zip Code

Can this be done? I played around with Chr(13) and vbcrlf but apparently I don't know how to use these in a string or this can't be done.

Thanks ahead of time for any help.
 
Hi Sullaway,

here is a function i use in reports, its basic but it will do what you want. put the function into a global module and call it from your report, set this as a data source for a text box and call it with the arguments (data items included from the query for the report). due to local differences you may need to change it a bit ;-)
set the text box property to can grow and it will fill the lines as required.

Function ReportAddress(Ad1 As Variant, ad2 As Variant, cty As Variant, State As Variant, PC As Variant)
Dim tempaddress As String
' Make address string for reports
' Robert K Dwyer 1-3-98
If Not IsNull(Ad1) Then
tempaddress = Ad1
Else
tempaddress = ""
End If
If Not IsNull(ad2) Then
tempaddress = tempaddress & vbCrLf
tempaddress = tempaddress & ad2
End If
If Not IsNull(cty) Then
tempaddress = tempaddress & vbCrLf
tempaddress = tempaddress & cty
End If
If Not IsNull(State) Then
tempaddress = tempaddress & " "
tempaddress = tempaddress & State
End If
If Not IsNull(PC) Then
tempaddress = tempaddress & " "
tempaddress = tempaddress & PC
End If
ReportAddress = tempaddress
End Function

HTH


Robert Dwyer
rdwyer@orion-online.com.au
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top