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

Formating Textboxes on forms

Status
Not open for further replies.

jimati

Programmer
Sep 28, 2007
20
US
I'm not sure I can explain this, but I'll try.

I'm trying to make the detail section look sort of like a spreadsheet. Meaning that there are rows and columns. Some of the "cells" or fields are set to "can grow" because some of the text is long and needs to wrap.

The problem is that when just one field wraps, the outline of that field is bigger, but the other fields in the same row remain smaller.

I'm not sure if that made sense.

In the onFormat, I tried to locate the textbox that has the biggest height and then set all the textboxes to that height, but onFormat doesn't actually have the updated field sizes yet. There would need to be an afterFormat or something.

onPrint shows the new sizes of the textboxes, but doesn't allow me set values to textboxes.

Any help or any other ideas would be great.

I'm sure you'll need further clarification, so ask away.
 
You need to remove the borders from all text boxes and use code in the On Print event of the report section to find the tallest control. Then use the Line method of the report to draw rectangles around controls.

This code expects you to enter the word "Border" in the tag property of every control in the section that you want to place a border around.

Code:
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
    Dim intMaxHeight As Integer
    Dim ctl As Control
    'Find highest control in Detail section _
      that has a tag property of "Border"
    For Each ctl In Me.Section(0).Controls
        If ctl.Tag = "Border" Then
            If ctl.Height > intMaxHeight Then
                intMaxHeight = ctl.Height
            End If
        End If
    Next
    'Draw a box around each control in Detail _
      that has a tag property of "Border"
    For Each ctl In Me.Section(0).Controls
        If ctl.Tag = "Border" Then
            Me.Line (ctl.Left, ctl.Top)- _
                Step(ctl.Width, intMaxHeight), vbBlack, B        
        End If
    Next
End Sub

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
That worked like a charm, thank you. One more question. Is there a way to center the text vertically in the textboxes? In one control, I have notes, which expands all the boxes. In another control, I have a date field. And becuase the notes field makes all the other fields increase in size (which it is supposed to), can I make the text center vertically in the box and not horizontally.

Thanks in advance.
 
You could try make your date text box (txtDate) invisible and using the Print method of the report to draw the value:
Code:
' previous code
            Me.Line (ctl.Left, ctl.Top)- _
                Step(ctl.Width, intMaxHeight), vbBlack, B
'new code
            Me.CurrentX = Me.txtDate.Left
            Me.CurrentY = (intMaxHeight) / 2 - 60
            Me.Print Me.txtDate
You may need to adjust the "60" based on your font size etc. The Me.CurrentX can be adjust also.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top