Dynamic placement of text boxes on a report

D

David Gabriel

I have a report designed where on the same line there are
two text boxes, e.g [Title] [Date]. I want the date to
appear at a fixed length from the title, as the length of
the title changes from record to record. I remember that
there is (or was) a function that returned the length of
text - not Len(*) - in inches or whatever the unit is, and
then there is a way to position another text box based by
providing a value, in this case the value returned plus a
certain margin. Any ideas? Much appreciated.
 
D

Duane Hookom

Can you use a single text box with a control source of:
=[Title] & " " & [Date]
You can also use the Print method of report to place the text anywhere you
want in the section.
 
D

David Gabriel

Yes,thank you, I know that and have used the Trim()
function for this elsewhere. I am sorry I wasn't more
specific,but in this case I am underlining the Title and
not the Date. I would like to move the Date to within one
or two character spaces of Title fr each record on the
report. Of course, if I could marry the two in your manner
and also underline the Title, I would be happy to do that.

Is there a way of formatting just a portion of a string or
text box?
-----Original Message-----
Can you use a single text box with a control source of:
=[Title] & " " & [Date]
You can also use the Print method of report to place the text anywhere you
want in the section.

--
Duane Hookom
MS Access MVP
--

David Gabriel said:
I have a report designed where on the same line there are
two text boxes, e.g [Title] [Date]. I want the date to
appear at a fixed length from the title, as the length of
the title changes from record to record. I remember that
there is (or was) a function that returned the length of
text - not Len(*) - in inches or whatever the unit is, and
then there is a way to position another text box based by
providing a value, in this case the value returned plus a
certain margin. Any ideas? Much appreciated.


.
 
D

Duane Hookom

Here is code that uses the Print method. This assumes you have the fields
bound to a couple invisible text boxes txtTitle and txtDate:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim intTop As Integer
intTop = 360 '1/4"
Me.CurrentX = 1440 '1" from left
Me.CurrentY = intTop
Me.FontUnderline = True
Me.Print Me.txtTitle
Me.FontUnderline = False
Me.CurrentY = intTop
Me.CurrentX = Me.CurrentX + 360 'move over 1/4"
Me.Print Me.txtdate
End Sub

--
Duane Hookom
MS Access MVP
--

David Gabriel said:
Yes,thank you, I know that and have used the Trim()
function for this elsewhere. I am sorry I wasn't more
specific,but in this case I am underlining the Title and
not the Date. I would like to move the Date to within one
or two character spaces of Title fr each record on the
report. Of course, if I could marry the two in your manner
and also underline the Title, I would be happy to do that.

Is there a way of formatting just a portion of a string or
text box?
-----Original Message-----
Can you use a single text box with a control source of:
=[Title] & " " & [Date]
You can also use the Print method of report to place the text anywhere you
want in the section.

--
Duane Hookom
MS Access MVP
--

David Gabriel said:
I have a report designed where on the same line there are
two text boxes, e.g [Title] [Date]. I want the date to
appear at a fixed length from the title, as the length of
the title changes from record to record. I remember that
there is (or was) a function that returned the length of
text - not Len(*) - in inches or whatever the unit is, and
then there is a way to position another text box based by
providing a value, in this case the value returned plus a
certain margin. Any ideas? Much appreciated.


.
 
A

AlCamp

David,
There's a much more elegant solution... concatenation.
Place just one field with a ControlSource of...
=[Title] & " " & [Date]
No matter how short or long Title is, the Date will appear 3 spaces after
it.

**Watch out with using the name [Date] for a field. Date is a reserved
word in Access, and represents your computers system date. Always identify
your date fields with a meaningful name (ex. DueDate, ExpirartionDate, etc
etc)
hth
Al Camp
 
M

Marshall Barton

David said:
I have a report designed where on the same line there are
two text boxes, e.g [Title] [Date]. I want the date to
appear at a fixed length from the title, as the length of
the title changes from record to record. I remember that
there is (or was) a function that returned the length of
text - not Len(*) - in inches or whatever the unit is, and
then there is a way to position another text box based by
providing a value, in this case the value returned plus a
certain margin.


If the title text box is guaranteed to be on one line, you
can use the TextWidth function (aftersetting the report
properties for the text box's Font, FontSize, Bole, etc.)

For a more general and easier to use function, download
Stephen Lebans fTextHeightWidth frunction from
www.lebans.com
 
D

david gabriel

Thanks!

Duane Hookom said:
Here is code that uses the Print method. This assumes you have the fields
bound to a couple invisible text boxes txtTitle and txtDate:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim intTop As Integer
intTop = 360 '1/4"
Me.CurrentX = 1440 '1" from left
Me.CurrentY = intTop
Me.FontUnderline = True
Me.Print Me.txtTitle
Me.FontUnderline = False
Me.CurrentY = intTop
Me.CurrentX = Me.CurrentX + 360 'move over 1/4"
Me.Print Me.txtdate
End Sub

--
Duane Hookom
MS Access MVP
--

David Gabriel said:
Yes,thank you, I know that and have used the Trim()
function for this elsewhere. I am sorry I wasn't more
specific,but in this case I am underlining the Title and
not the Date. I would like to move the Date to within one
or two character spaces of Title fr each record on the
report. Of course, if I could marry the two in your manner
and also underline the Title, I would be happy to do that.

Is there a way of formatting just a portion of a string or
text box?
-----Original Message-----
Can you use a single text box with a control source of:
=[Title] & " " & [Date]
You can also use the Print method of report to place the text anywhere you
want in the section.

--
Duane Hookom
MS Access MVP
--

I have a report designed where on the same line there are
two text boxes, e.g [Title] [Date]. I want the date to
appear at a fixed length from the title, as the length of
the title changes from record to record. I remember that
there is (or was) a function that returned the length of
text - not Len(*) - in inches or whatever the unit is, and
then there is a way to position another text box based by
providing a value, in this case the value returned plus a
certain margin. Any ideas? Much appreciated.


.
 
Top