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

Act report field spacing 1

Status
Not open for further replies.

cobras

Technical User
Jun 13, 2007
7
US
I have created a new report but cannot get the spaces between the city, state and zip fields to collapse.

In the field properties, I have set the behavior to 'can shrink'.

it should come out; City, ST Zip

depending on the field length, this is how they are; City St Zip

since the city name can vary in length, the field should adjust longer or shorter and collapse the space between it and the state field. this was easy in previous versions!

thanks!
 
This is actually more complicated than it seems prima facie. Have a look at some of the default reports that include city/state/zip fields.

File > Print > Labels > Avery 5160 > EDIT TEMPLATE

Now that you're in the report editor, you'll notice that instead of CSZ fields, there is actually two 'custom' fields, one named Custom1 and the other Custom2. Custom1 is what we're concerned with here.

Also note that this report does contain City1, State1, and Zip1 fields, they are just 'hidden'. They need to be on the report though so the VB script can reference them and populate the Custom1 field.

Now right-click on the report section (the grid area, not the gray area) and go to Edit Scripts.

That is the code that ties it all together using Visual Basic.

Code:
If City1 = NULL THEN
    Custom1.Text = City1&" "&State1&" "&ZIPCode1
Else
    Custom1.Text = City1&", "&State1&" "&ZIPCode1
End If

That is the main body of the example reports code that we're concerned with. Here is what it means:

Line1: If the City1 field does not contain any data, the Line2: Custom1 field should read "[City]State ZIP"
Line3: Otherwise
Line4: Custom1 field should read "City, State, ZIP"

That is how you get those three fields to line up regardless of how long the data is in each of them. Each object is anchored into position by coordinates; the object's distance from the top of the section, and the object's distance from the left edge of the section.

Fun, eh?

Cheers,


~Melagan
______
"It's never too late to become what you might have been.
 
...unless someone else knows an easier way =)


~Melagan
______
"It's never too late to become what you might have been.
 
Thank you, Melagan!

Just finding the script was key. Then, after playing around I hit that Ah-ha moment. Of course, that meant I had to add a few more things too, just because I could.

Thanks again.
 
Francis,

Thank you for that link! I searched Act help and TS for hours, it seemed like, and could not find the description you provided. I tried every combination of descriptive words I could think of to no avail. I knew the answer was there somewhere, just couldn't get to it. Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top