I have a text field in a table and want to display it on a report within boxes.
For example, the field might say TRLU123456
I need to get the T in a box or put a border round it, then the R etc etc etc.
The field length can change so if I just draw boxes over the control the
data may move around underneath it?
Any ideas please
Easy enough.
Let's assume the largest amount of text will be 16 characters.
Adjust as necessary.
Add 16 unbound text controls to your report.
An easy way to add 16 controls is to add 1. Select it Copy and paste.
Select these 2, Copy and Paste, Select these 4, Copy and paste, etc.
Delete all of their labels. Size the controls to whatever height and
width will work. Name them "Text1", "Text2", etc... "Text16".
Position them in order, left to right.
Space them using Format + Horizontal Spacing Make Equal. Align them.
Set their Border Style to Solid, Border Width to 1 pt size.
Code the Report Section's Format event.
If they're in the Detail section, then:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim intX As Integer
Dim intY As Integer
intX = 1
For intX = 1 To Len([FieldName])
Me("Text" & intX) = Mid([FieldName], intX, 1)
Me("Text" & intX).Visible = True
Next intX
' To hide extra boxes or to show empty boxes
For intY = intX To 16
Me("Text" & intY).Visible = False ' To hide extra boxes
' Me("Text" & intY) = "" ' To show the box but delete the text
Next intY
End Sub
Set the control's FontSize to one that will match the size of the
box. Set the Alignment to Center.