Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.ms-access > #9779 > unrolled thread

'Continued' label in Group Header when using Repeat Section - Solved

Started byCDMAPoster@fortunejames.com
First post2014-08-14 06:55 -0700
Last post2014-08-15 06:03 -0700
Articles 5 — 2 participants

Back to article view | Back to comp.databases.ms-access


Contents

  'Continued' label in Group Header when using Repeat Section - Solved CDMAPoster@fortunejames.com - 2014-08-14 06:55 -0700
    Re: 'Continued' label in Group Header when using Repeat Section - Solved "Phil" <phil@stantonfamily.co.uk> - 2014-08-14 18:57 +0100
      Re: 'Continued' label in Group Header when using Repeat Section - Solved CDMAPoster@fortunejames.com - 2014-08-14 15:29 -0700
        Re: 'Continued' label in Group Header when using Repeat Section - Solved "Phil" <phil@stantonfamily.co.uk> - 2014-08-15 09:26 +0100
          Re: 'Continued' label in Group Header when using Repeat Section - Solved CDMAPoster@fortunejames.com - 2014-08-15 06:03 -0700

#9779 — 'Continued' label in Group Header when using Repeat Section - Solved

FromCDMAPoster@fortunejames.com
Date2014-08-14 06:55 -0700
Subject'Continued' label in Group Header when using Repeat Section - Solved
Message-ID<00b5fb28-d596-4e1c-ad1e-68dc33078639@googlegroups.com>
I have an Access Report with information about each quote grouped by Customer, so I have a Customer header that has column headings.  I wanted the column headings to be at the top of each page of the report, so in the GroupHeader0 properties I set the Repeat Section property to Yes.  Then I decided that to the right of the Customer textbox in the customer header, I wanted to put a hidden label called lblContinue containing the caption '(Cont.)'.  I wanted that label to be visible when the Customer Header started on a previous page, but not visible when it started at the top of that page.  Here's the code I used:

'---begin code behind report
Option Compare Database
Option Explicit

Dim boolPageHeader As Boolean
Dim strCurrentCustomer As String

Private Sub GroupHeader0_Format(Cancel As Integer, FormatCount As Integer)
'If a specific customer is selected, show lblContinued after first page.
If Not IsNull(Forms!frmAwardedReport!cbxCustomer.Value) Then
  If boolPageHeader = True And [Page] <> 1 Then
    lblContinued.Visible = True
  Else
    lblContinued.Visible = False
  End If
  Exit Sub
End If
If boolPageHeader = True And [Page] <> 1 Then
  lblContinued.Visible = True
  boolPageHeader = False
Else
  lblContinued.Visible = False
End If
End Sub

Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As Integer)
strCurrentCustomer = Nz(txtCustomer.Value, "")
End Sub

Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As Integer)
If [Page] = 1 Then Exit Sub
If txtCustomer.Value = strCurrentCustomer Then
  boolPageHeader = True
Else
  'Fresh customer, so '(Cont.)' can't apply.  Act like code isn't in header.
  boolPageHeader = False
End If
End Sub

Private Sub Report_Open(Cancel As Integer)
If Not IsFormOpen("frmAwardedReport") Then
  MsgBox ("This form must be opened from the Awarded Report form.")
  Cancel = True
  Exit Sub
End If
boolPageHeader = False
lblDateRange.Caption = "Submitted Dates from " & Format(Forms!frmAwardedReport!txtStartDate.Value, "m/d/yy") & " to " & Format(Forms!frmAwardedReport!txtEndDate.Value, "m/d/yy")
If Not IsNull(Forms!frmAwardedReport!cbxCustomer.Value) Then
  'Me.RecordSource = "SQL to get quotes for specific customer"
Else
  'Me.RecordSource = "SQL to get quotes for all customers"
End If
End Sub
'-----end code behind report

'---begin module code
Public Function IsFormOpen(strForm As String) As Boolean
Dim frmX As Form

IsFormOpen = False
For Each frmX In Forms
  If frmX.Name = strForm Then
    IsFormOpen = True
    Exit For
  End If
Next frmX
End Function
'-----end module code

James A. Fortune
CDMAPoster@FortuneJames.com

[toc] | [next] | [standalone]


#9787

From"Phil" <phil@stantonfamily.co.uk>
Date2014-08-14 18:57 +0100
Message-ID<lsitav$832$1@speranza.aioe.org>
In reply to#9779
On 14/08/2014 14:55:06,  wrote:
> I have an Access Report with information about each quote grouped by
> Custom er, so I have a Customer header that has column headings. I wanted
> the col umn headings to be at the top of each page of the report, so in
> the GroupHe ader0 properties I set the Repeat Section property to Yes.
> Then I decided that to the right of the Customer textbox in the customer
> header, I wanted to put a hidden label called lblContinue containing the
> caption '(Cont.)'. I wanted that label to be visible when the Customer
> Header started on a pr evious page, but not visible when it started at the
> top of that page. Here 's the code I used:
> 
> '---begin code behind report
> Option Compare Database
> Option Explicit
> 
> Dim boolPageHeader As Boolean
> Dim strCurrentCustomer As String
> 
> Private Sub GroupHeader0_Format(Cancel As Integer, FormatCount As Integer)
> 'If a specific customer is selected, show lblContinued after first page.
> If Not IsNull(Forms!frmAwardedReport!cbxCustomer.Value) Then If
> boolPageHeader = True And [Page] <> 1 Then lblContinued.Visible = True
> Else
> lblContinued.Visible = False
> End If
> Exit Sub
> End If
> If boolPageHeader = True And [Page] <> 1 Then
> lblContinued.Visible = True
> boolPageHeader = False
> Else
> lblContinued.Visible = False
> End If
> End Sub
> 
> Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As
> Inte ger)
> strCurrentCustomer = Nz(txtCustomer.Value, "")
> End Sub
> 
> Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As
> Inte ger)
> If [Page] = 1 Then Exit Sub
> If txtCustomer.Value = strCurrentCustomer Then
> boolPageHeader = True
> Else
> 'Fresh customer, so '(Cont.)' can't apply.  Act like code isn't in header
> .
> boolPageHeader = False
> End If
> End Sub
> 
> Private Sub Report_Open(Cancel As Integer)
> If Not IsFormOpen("frmAwardedReport") Then
> MsgBox ("This form must be opened from the Awarded Report form.")
> Cancel = True
> Exit Sub
> End If
> boolPageHeader = False
> lblDateRange.Caption = "Submitted Dates from " & Format(Forms!frmAwardedR
> eport!txtStartDate.Value, "m/d/yy") & " to " &
> Format(Forms!frmAwardedRepor t!txtEndDate.Value, "m/d/yy")
> If Not IsNull(Forms!frmAwardedReport!cbxCustomer.Value) Then
> 'Me.RecordSource = "SQL to get quotes for specific customer"
> Else
> 'Me.RecordSource = "SQL to get quotes for all customers"
> End If
> End Sub
> '-----end code behind report
> 
> '---begin module code
> Public Function IsFormOpen(strForm As String) As Boolean
> Dim frmX As Form
> 
> IsFormOpen = False
> For Each frmX In Forms
> If frmX.Name = strForm Then
> IsFormOpen = True
> Exit For
> End If
> Next frmX
> End Function
> '-----end module code
> 
> James A. Fortune
> CDMAPoster@FortuneJames.com
> 

Try this (Sorry, [Type] is the groupheader field name - yes I know Type is a
reserved word...) The field Type is Visible = No
the Field TxtTpe is a label

Option Compare Database
Option Explicit

    Dim HoldType As String

Private Sub GroupHeader0_Format(Cancel As Integer, FormatCount As Integer)

    If HoldType = [Type] Then
        TxtType.Caption = [Type] & " (continued)"
    Else
        TxtType.Caption = [Type]
        HoldType = [Type]
    End If
    
End Sub

Phil

---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com

[toc] | [prev] | [next] | [standalone]


#9790

FromCDMAPoster@fortunejames.com
Date2014-08-14 15:29 -0700
Message-ID<9f61faf3-9b59-400d-a59c-3a55dac5a830@googlegroups.com>
In reply to#9787
On Thursday, August 14, 2014 1:57:51 PM UTC-4, Phil wrote:
 
> Try this (Sorry, [Type] is the groupheader field name - yes I know Type is a
> 
> reserved word...) The field Type is Visible = No
> 
> the Field TxtTpe is a label
> 
> 
> 
> Option Compare Database
> 
> Option Explicit
> 
> 
> 
>     Dim HoldType As String
> 
> 
> 
> Private Sub GroupHeader0_Format(Cancel As Integer, FormatCount As Integer)
> 
> 
> 
>     If HoldType = [Type] Then
> 
>         TxtType.Caption = [Type] & " (continued)"
> 
>     Else
> 
>         TxtType.Caption = [Type]
> 
>         HoldType = [Type]
> 
>     End If
> 
>     
> 
> End Sub
> 
> 
> 
> Phil
> 
> 
> 
> ---
> 
> This email is free from viruses and malware because avast! Antivirus protection is active.
> 
> http://www.avast.com

I liked the idea of trying to use the label's caption to display both the field and the (Cont.) part in attempt to simplify the code, but your code put (Cont.) at the top of the page when it shouldn't be there, plus it put it in other group headers on the page.  Sometimes the group header format code is called more than once and could throw a proverbial monkey wrench into your logic.  Good effort.  I'm starting to think the code I posted might help someone :-).

James A. Fortune
CDMAPoster@FortuneJames.com

[toc] | [prev] | [next] | [standalone]


#9793

From"Phil" <phil@stantonfamily.co.uk>
Date2014-08-15 09:26 +0100
Message-ID<lskg86$q5p$1@speranza.aioe.org>
In reply to#9790
On 14/08/2014 23:29:36,  wrote:
> On Thursday, August 14, 2014 1:57:51 PM UTC-4, Phil wrote:
> 
>> Try this (Sorry, [Type] is the groupheader field name - yes I know Type i
> s a
>>
>> reserved word...) The field Type is Visible = No
>>
>> the Field TxtTpe is a label
>>
>>
>>
>> Option Compare Database
>>
>> Option Explicit
>>
>>
>>
>>     Dim HoldType As String
>>
>>
>>
>> Private Sub GroupHeader0_Format(Cancel As Integer, FormatCount As Integer
> )
>>
>>
>>
>>     If HoldType = [Type] Then
>>
>>         TxtType.Caption = [Type] & " (continued)"
>>
>>     Else
>>
>>         TxtType.Caption = [Type]
>>
>>         HoldType = [Type]
>>
>>     End If
>>
>>
>>
>> End Sub
>>
>>
>>
>> Phil
>>
>>
>>
>> ---
>>
>> This email is free from viruses and malware because avast! Antivirus prot
> ection is active.
>>
>> http://www.avast.com
> I liked the idea of trying to use the label's caption to display both the
> f ield and the (Cont.) part in attempt to simplify the code, but your code
> pu t (Cont.) at the top of the page when it shouldn't be there, plus it
> put it in other group headers on the page. Sometimes the group header
> format cod e is called more than once and could throw a proverbial monkey
> wrench into your logic. Good effort. I'm starting to think the code I
> posted might he lp someone :-).
> 
> James A. Fortune
> CDMAPoster@FortuneJames.com
> 

Not quite with you then, James.
Is this a 2 column report, or single column. Works fine for me as a single
column report. With a 2 column report, for example half way down the left
hand column, I get “Member” as the group header, and then “Member
(continued)” at the top of the right hand column. The “Member (continued) is
at the top of both columns on subsequent pages, until the group header
changes. Are you saying you only want the “Member (continued)” on the left
hand column and blank on the right hand column?

Phil

---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com

[toc] | [prev] | [next] | [standalone]


#9794

FromCDMAPoster@fortunejames.com
Date2014-08-15 06:03 -0700
Message-ID<557f3746-cc84-459c-916c-4fe33388a7f2@googlegroups.com>
In reply to#9793
On Friday, August 15, 2014 4:26:43 AM UTC-4, Phil wrote:

> Not quite with you then, James.
> 
> Is this a 2 column report, or single column. Works fine for me as a single
> 
> column report. With a 2 column report, for example half way down the left
> 
> hand column, I get �Member� as the group header, and then �Member
> 
> (continued)� at the top of the right hand column. The �Member (continued) is
> 
> at the top of both columns on subsequent pages, until the group header
> 
> changes. Are you saying you only want the �Member (continued)� on the left
> 
> hand column and blank on the right hand column?
> 
> 
> 
> Phil

The report in question is a simple report.  The textbox holds the customer and the label after it is used to show the '(Cont.)' portion.  Both controls are within the only Group Header section on the report.  The '(Cont.)' portion is to show only when the page header generated by the 'Repeat Section' property is not the beginning of the group header (most common situation).  I thought your idea was innovative because Access doesn't allow you to change the textbox contents, but it does allow you to change the label caption in the Group Header Format code.  In order to get the correct results, you will have to add more code, so while it's possible that your idea could simplify the code somewhat, there's not much room for much simplification once that code is added.

James A. Fortune
CDMAPoster@FortuneJames.com

[toc] | [prev] | [standalone]


Back to top | Article view | comp.databases.ms-access


csiph-web