I'm using TextWidth to format a report but it doesn't seem to be returning accurate results. To test what was going on I added the following code which should place the object TestLine lined up the text and set its length to the width of the text, essentially an underline.
Me.TestLine.Left = txtData.Left + intMargin
Me.TestLine.Width = TextWidth(txtData.Value)
In the preview of the report the "underline" is sometimes bang on the correct length but more often than not it is as much as 50% longer than the actual text. I've checked the font and size parameters and they all match up. I've also checked the values of each term in the above equations - the line drawn is correct based on these numbers. I'm fairly certain TextWidth is indeed returning over sized values, I just can't see a reason for it or a way round it.
My full code is loosely based on Lebans' leaderdots function (found here) which someone here kindly pointed me at last week. I notice is that sample project the same thing appears to be occurring (at least on my computer) - in that case it manifests as the dotted lines sometimes running right up to the data values they're associated with and sometimes stopping significantly short.
Any suggestions/ideas?
EDIT: I've attached a screen cap of how far short the dots sometimes fall including the "underline" I added indicating how long TextWidth is calculating my text to be.
Me.TestLine.Left = txtData.Left + intMargin
Me.TestLine.Width = TextWidth(txtData.Value)
In the preview of the report the "underline" is sometimes bang on the correct length but more often than not it is as much as 50% longer than the actual text. I've checked the font and size parameters and they all match up. I've also checked the values of each term in the above equations - the line drawn is correct based on these numbers. I'm fairly certain TextWidth is indeed returning over sized values, I just can't see a reason for it or a way round it.
My full code is loosely based on Lebans' leaderdots function (found here) which someone here kindly pointed me at last week. I notice is that sample project the same thing appears to be occurring (at least on my computer) - in that case it manifests as the dotted lines sometimes running right up to the data values they're associated with and sometimes stopping significantly short.
Any suggestions/ideas?
EDIT: I've attached a screen cap of how far short the dots sometimes fall including the "underline" I added indicating how long TextWidth is calculating my text to be.
Attachments
Last edited: