Click to See Complete Forum and Search --> : Is it possible to measure a string in inches?
Wenin
November 8th, 2007, 09:28 AM
I'm wanting to be able to create a formula that will do the following.
Given a string, I want to add a number of ...... in order to make the entire string a certain length in inches. This would allow me to do the following
cat ...........
bird ..........
dog ..........
alligator ...
Is this somehow possible? =)
Wenin
November 8th, 2007, 09:30 AM
I'm fairly certain that this isn't possible, but I felt a need to ask in order to state to my client that it just can't be done. =)
jggtz
November 8th, 2007, 12:59 PM
Could be if you use a fixed font, that way you'll know how many characters 'fill' an inch
Wenin
November 8th, 2007, 02:44 PM
Ok, given a specific font, such as Arial, how would you do it?
In Arial
wwwww
is longer than
iiiii
Even though they have the same character count.
dglienna
November 8th, 2007, 08:48 PM
Use the TextWidth Property. It should work the same.
Private Sub Form_Click ()
Dim HalfHeight, HalfWidth, Msg ' Declare variables.
AutoRedraw = -1 ' Turn on AutoRedraw.
BackColor = QBColor(4) ' Set background color.
ForeColor = QBColor(15) ' Set foreground color.
Msg = "Visual Basic" ' Create message.
FontSize = 48 ' Set font size.
HalfWidth = TextWidth(Msg) / 2 ' Calculate one-half width.
HalfHeight = TextHeight(Msg) / 2 ' Calculate one-half height.
CurrentX = ScaleWidth / 2 - HalfWidth ' Set X.
CurrentY = ScaleHeight / 2 - HalfHeight ' Set Y.
Print Msg ' Print message.
End Sub
Wenin
November 9th, 2007, 09:39 AM
Oh please return and explain where I would put VB programming within a Crystal Report?
I realize I didn't make my situation clear. Since the parent forum is "VB Programming", I should have.
I'm needing to do this all within Crystal Reports. I do not have control over the application that is utilizing the Crystal Report.
jggtz
November 9th, 2007, 11:46 AM
"fixed font" is the key
Arial isn't a fixed font, Courier is
Wenin
November 9th, 2007, 12:54 PM
Well of course, but the client isn't willing to go with Courier font. =)
JaganEllis
November 11th, 2007, 05:44 PM
The size of the field on the designer means that, for example, even if your formula returned a string of 300 characters then only those that are visible within the field's width are displayed.
So simply add a whole load of dots (however many fit into your field width) and use the field width itself to perform the 'truncation'.
e.g. your formula could be
{table.field} & ReplicateString(".",100)
dglienna
November 11th, 2007, 07:21 PM
Nope, use "M" which is the BIGGEST character. Access creates CR objects, and an Access VBA Macro can use obj.textwidth to return the data.
Wenin
November 11th, 2007, 08:13 PM
JaganEllis, the way Crystal Reports is implemented within the application I'm working with, the report is generated directly to a Word Document. All of the characters are displayed.
I'm not following you dglienna. I have to be able to do everything within the Crystal Reports application. The report isn't connected directly to the database, but instead uses a Field Definition file (TTX).
dglienna
November 11th, 2007, 08:19 PM
Access 2007 has Crystal built into it, so I can open a report, and then add vba code, or run a built in macro. I'm assuming that it's the same report that you use.
Wenin
November 12th, 2007, 12:01 AM
I'm essentially using Crystal Reports as a standalone application, that creates an RPT file that I then upload into a web based application. I don't know all the details of what the web based application does, but it is using Crystal Reports based engine to then generate a word document that is then provided to the end user as a download.
Does your method create an RPT file or do you have the ability to create an RPT file of a report you've built within Access 2007? If so, I like to ask for a copy of the RPT file to look at it. I can PM you my email address.
I'm using Crystal 11.
Thanks
Lugh
November 14th, 2007, 11:51 AM
OK, I think I've got it.
The only question will be whether or not it exports to Word properly. It did for me, but I have constant issues with the export being inconsistent.
Create your textbox with the data in it. You need two important format changes. First, change the background to White (assuming the background of your report is white, but it needs to not be transparent). Second, under the Border tab, turn on Tight Horizontal (this sizes the border of the field to the data value).
Now, create a textbox that runs the entire width, from the beginning of the data field, to the end of the area where the customer wants the periods. Fill the textbox with periods. Move the textbox to the back. Right-align it.
What this does is create a line of periods for each record, then cover it up with just the data in the field. This makes it look like you created a line of periods with custom length.
Wenin
November 14th, 2007, 01:31 PM
Crafty, but in the environment I'm working with, both fields would be printed in their entirety. When they are exported to word, everything is exported... and word can't have text on top of text as far as I know. So either one of the fields will be foreced to a new line, or one would follow the other... in their entirety.
I'm really thinking this just isn't possible.
Lugh
November 15th, 2007, 08:41 AM
I'd recommend giving it a try. I exported it to Word, and it worked perfectly. But, depending on how it exports, I admit that it may not work for you. But, it can't hurt to try, right?
jggtz
November 15th, 2007, 12:18 PM
Use a Formula like --->
Trim({Tbl.Field}) + ReplicateString ("-",10 - (Length (Trim({Tbl.Field}))))
(10 is just for the example, you can change it)
Place in proper report section
Then, Format the Field and in the Font tab set 'Character spacing exactly ___ pts'
Try 6 or 7 or anyother that fits your needs
Lugh
November 15th, 2007, 02:48 PM
An important question, though, is whether that fixed font will be preserved when the report is exported. Otherwise, yes, that is a very good solution.
codeguru.com
Copyright WebMediaBrands Inc., All Rights Reserved.