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!

Easy report formatting question

Status
Not open for further replies.

qwkphkr

IS-IT--Management
Aug 18, 2006
8
US
Hello all,

I basically wanted to know if there is a way to create a horizontal "can grow" vs the obvious vertical one? Any help is appreciated.

Tony
 
It is possible to format controls on the fly:
Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
'Approx 567 twip/cm
If Len(Me.AText) > 5 Then
    Me.AText.Left = 200
    Me.AText.Width = 2500
Else
    Me.AText.Left = 2000
    Me.AText.Width = 250
End If
End Sub
 
I'm not to familiar with vba, I know that this goes in the event field, but which one?
 
It is a Format event for Detail:
[tt]Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)[/tt]

After that, you will have to play around with VBA. You will need to decide what change in a field or control will cause this particular control to grow.

[tt]Me.AText.Left[/tt]
Moves the position.

The reason there is no standard way of doing this is that it is, I think, quite an unusual thing to do. Perhaps you can rethink your layout and find a way around? These events can slow reports down.
 
Thank you for all the help so far. It might help to explain further, I have a name field in my table for "Firstname", "Lastname" and "Middlename". When I generate and invoice for this customer, my goal was to have the spacing normal rather than have to create a field in the report that was large enough to accomodate any size name I get in the table. Does that make sense? I'm not really sure that it's necessary to have the names broken down in this manner however I felt that from a data manipulation standpoint (sorting and searching primarily) it would be best. Any further thoughts?
 
I think you will find that the best bet is to have the name at the right size for the window envelopes or labels that you use.
 
Yes, but for example if you have three customers. One named Ted, one named Tony, and one named Josephina, when you format the report it will look like this:

Ted Jones v/s Ted Jones
Tony Smith v/s Tony Smith
Josephina Maggio v/s Josephina Maggio

Because the firstname field has to be sized to accomodate the largest firstname you have in the table.
 
have you combined the names in the query to a single field? That may accomplish what you are trying to do:

SELECT FirstName & " " & LastName From TableName

should return

Ted Jones
Tony Smith
Josephina Maggio

with a single space between the first and last names.


Leslie

Anything worth doing is a lot more difficult than it's worth - Unknown Induhvidual

Essential reading for anyone working with databases:
The Fundamentals of Relational Database Design
Understanding SQL Joi
 
that's exactly the trick I needed, thanks to everyone!!

Tony
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top