A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Setting Up & Running Reports
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Labels in group headers question



 
 
Thread Tools Display Modes
  #1  
Old December 5th, 2005, 12:35 AM posted to microsoft.public.access.reports
external usenet poster
 
Posts: n/a
Default Labels in group headers question

I have a report in which there is a bound control (ID) in the group header. I
have put a label in the same section and want it to display text based on the
number in the ID control. I have tried the following and it won't work. I am
not sure at what point in the report loading I would place it either (if you
are able to do this in reports).

Private Sub Report_Activate()
srtNum = Me.ID

If strNum = 3 Then
lblBudgetText.Caption = " This is label 3"
End If

If strNum = 4 Then
lblBudgetText.Caption = "This is label 4"
End If

End Sub

Any help would be appreciated.

  #2  
Old December 5th, 2005, 12:58 AM posted to microsoft.public.access.reports
external usenet poster
 
Posts: n/a
Default Labels in group headers question

On Sun, 4 Dec 2005 16:35:02 -0800, BobbyS wrote:

I have a report in which there is a bound control (ID) in the group header. I
have put a label in the same section and want it to display text based on the
number in the ID control. I have tried the following and it won't work. I am
not sure at what point in the report loading I would place it either (if you
are able to do this in reports).

Private Sub Report_Activate()
srtNum = Me.ID

If strNum = 3 Then
lblBudgetText.Caption = " This is label 3"
End If

If strNum = 4 Then
lblBudgetText.Caption = "This is label 4"
End If

End Sub

Any help would be appreciated.


There are a couple of problems with your approach.

1) The Report Activate event only fires when the report is previewed,
not when it's printed.

2) The Activate event would only read the value of the very first
record and not any additional ones.

3) Place your code in the Format event of the Group Header.

Me![lblBudgetText].Caption = " This is label " & Me![ID]

No need to create a variable to read the ID value as long as that same
value is to be used in the caption.
The Label caption will change as the ID changes.

4) An easier solution would be to change the label to an unbound text
control. As it's control source, write:
="This is Label " & Me![ID]
No VBA code is required.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Option Group Label Issue Jay Using Forms 8 November 8th, 2005 01:51 PM
Survey Results SAm Running & Setting Up Queries 10 May 17th, 2005 08:32 PM
ambiguous outer joins renwick Running & Setting Up Queries 3 February 22nd, 2005 01:29 PM
Mail Merge Problem MT DOJ Help Desk General Discussion 9 July 20th, 2004 04:55 AM
Help Needed for Groups Please Paul Black General Discussion 15 June 21st, 2004 02:54 AM


All times are GMT +1. The time now is 07:03 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.