Center Text

  • Thread starter pib311 via AccessMonster.com
  • Start date
P

pib311 via AccessMonster.com

Hello all,

I have what would seem to be a very small problem, but I am unable to answer
it myself. I have a report that I am trying to create and each record can
have one of three categories. If there are multiple records for, let's say,
Group1, then I want a text box to span both records and center the text
within the report. This would be the equivalent of a rowspan in html.

I have no idea where to start. Am I missing something really simple?

The data is structured as the following:

Group1 | Record 1 | Some cool info
Group1 | Record 2 | Some cool info
Group 2 | Record 1 | Some cool info
 
D

Duane Hookom

You have shown us your data but haven't provided how you would like it to
appear on the report. In HTML, I think you are looking for a dynamic
<td rowspan='x' valign='center'>
where the value of x could vary from 1 to many.

If you have three Group1, then centering is fairly well defined. There is no
center row if you have an even number of records in Group1.

Is there a minimum number of records in a group?

I think you might be able to use a group count combined with a running sum
text box to display or hide a value in the detail section.
 
P

pib311 via AccessMonster.com

Duane,

Thanks for the suggestions.

The Group1 could be anywhere from 1 to 10. To show a physical representation
of what I need, it would look something this:

_______
| Row 1 | Some data
Group1 | Row2 | Some data
_______| Row 3 | Some data

I am a little confused as to how the running sum and a group count could be
used. Please elaborate.

Thanks in advance.

Duane said:
You have shown us your data but haven't provided how you would like it to
appear on the report. In HTML, I think you are looking for a dynamic
<td rowspan='x' valign='center'>
where the value of x could vary from 1 to many.

If you have three Group1, then centering is fairly well defined. There is no
center row if you have an even number of records in Group1.

Is there a minimum number of records in a group?

I think you might be able to use a group count combined with a running sum
text box to display or hide a value in the detail section.
Hello all,
[quoted text clipped - 11 lines]
Group1 | Record 2 | Some cool info
Group 2 | Record 1 | Some cool info
 
D

Duane Hookom

I tried this a while back answering a similar question. I used the Northwind
sample database with the Order Details table. I grouped by OrderID which
would correspond with your Group field. I added a group header with a text
box:
Name: txtRecords
Control Source: =Count(*)
In the detail section, add a text box:
Name: txtCount
Control Source: =1
Running Sum: Over Group
Visible: No
Add another text box for your Group title (txtGrpTitle).
Then use code in the On Format event of the detail section:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim intMidRecord As Integer
intMidRecord = (Me.txtRecords + 1) \ 2
Me.txtGrpTitle.Visible = (intMidRecord = Me.txtCount)
'draw vertical lines on left and right
Me.Line (Me.txtGrpTitle.Left, 0)-Step(0, Me.Height)
Me.Line (Me.txtGrpTitle.Left + Me.txtGrpTitle.Width, 0)-Step(0, Me.Height)
If Me.txtCount = 1 Then 'first record in group
Me.Line (Me.txtGrpTitle.Left, 0)-Step(Me.txtGrpTitle.Width, 0)
End If
If Me.txtCount = Me.txtRecords Then 'last record in group
Me.Line (Me.txtGrpTitle.Left, Me.Height)-Step(Me.txtGrpTitle.Width, 0)
End If
End Sub

--
Duane Hookom
Microsoft Access MVP


pib311 via AccessMonster.com said:
Duane,

Thanks for the suggestions.

The Group1 could be anywhere from 1 to 10. To show a physical representation
of what I need, it would look something this:

_______
| Row 1 | Some data
Group1 | Row2 | Some data
_______| Row 3 | Some data

I am a little confused as to how the running sum and a group count could be
used. Please elaborate.

Thanks in advance.

Duane said:
You have shown us your data but haven't provided how you would like it to
appear on the report. In HTML, I think you are looking for a dynamic
<td rowspan='x' valign='center'>
where the value of x could vary from 1 to many.

If you have three Group1, then centering is fairly well defined. There is no
center row if you have an even number of records in Group1.

Is there a minimum number of records in a group?

I think you might be able to use a group count combined with a running sum
text box to display or hide a value in the detail section.
Hello all,
[quoted text clipped - 11 lines]
Group1 | Record 2 | Some cool info
Group 2 | Record 1 | Some cool info

--



.
 
P

pib311 via AccessMonster.com

Perfect, This is exactly what I need.

I am sorry for the late response, been out of the office.

Duane said:
I tried this a while back answering a similar question. I used the Northwind
sample database with the Order Details table. I grouped by OrderID which
would correspond with your Group field. I added a group header with a text
box:
Name: txtRecords
Control Source: =Count(*)
In the detail section, add a text box:
Name: txtCount
Control Source: =1
Running Sum: Over Group
Visible: No
Add another text box for your Group title (txtGrpTitle).
Then use code in the On Format event of the detail section:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim intMidRecord As Integer
intMidRecord = (Me.txtRecords + 1) \ 2
Me.txtGrpTitle.Visible = (intMidRecord = Me.txtCount)
'draw vertical lines on left and right
Me.Line (Me.txtGrpTitle.Left, 0)-Step(0, Me.Height)
Me.Line (Me.txtGrpTitle.Left + Me.txtGrpTitle.Width, 0)-Step(0, Me.Height)
If Me.txtCount = 1 Then 'first record in group
Me.Line (Me.txtGrpTitle.Left, 0)-Step(Me.txtGrpTitle.Width, 0)
End If
If Me.txtCount = Me.txtRecords Then 'last record in group
Me.Line (Me.txtGrpTitle.Left, Me.Height)-Step(Me.txtGrpTitle.Width, 0)
End If
End Sub
[quoted text clipped - 30 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top