dbTalk Databases Forums  

Alter Report Captions from a Subform

comp.databases.ms-access comp.databases.ms-access


Discuss Alter Report Captions from a Subform in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
bobdydd
 
Posts: n/a

Default Alter Report Captions from a Subform - 06-21-2011 , 03:39 PM






Hi

I have a Main Form with Subform
I have a Report that opens on a query that restricts it to a single
record

On the report there are Labels whose captions I need to alter
depending what records are showing on the subform. But I am only
getting it to work on the first Label. Grateful for any help

Private Sub Report_Open(Cancel As Integer)
DoCmd.Maximize
If Forms![frmSite]![zfrmSiteProductLeft].Form![ComboProductID] = 1
Then
Me.lbl_1.Caption = 9
End If

If Forms![frmSite]![zfrmSiteProductLeft].Form![ComboProductID] = 2
Then
Me.lbl_2.Caption = 9
End If

If Forms![frmSite]![zfrmSiteProductLeft].Form![ComboProductID] = 3
Then
Me.lbl_3.Caption = 9
End If

If Forms![frmSite]![zfrmSiteProductLeft].Form![ComboProductID] = 4
Then
Me.lbl_4.Caption = 9
End Sub

Reply With Quote
  #2  
Old   
John W. Vinson
 
Posts: n/a

Default Re: Alter Report Captions from a Subform - 06-21-2011 , 04:30 PM






On Tue, 21 Jun 2011 13:39:07 -0700 (PDT), bobdydd
<reallyuseful2004 (AT) yahoo (DOT) co.uk> wrote:

Quote:
Hi

I have a Main Form with Subform
I have a Report that opens on a query that restricts it to a single
record

On the report there are Labels whose captions I need to alter
depending what records are showing on the subform. But I am only
getting it to work on the first Label. Grateful for any help

Private Sub Report_Open(Cancel As Integer)
DoCmd.Maximize
If Forms![frmSite]![zfrmSiteProductLeft].Form![ComboProductID] = 1
Then
Me.lbl_1.Caption = 9
End If

If Forms![frmSite]![zfrmSiteProductLeft].Form![ComboProductID] = 2
Then
Me.lbl_2.Caption = 9
End If

If Forms![frmSite]![zfrmSiteProductLeft].Form![ComboProductID] = 3
Then
Me.lbl_3.Caption = 9
End If

If Forms![frmSite]![zfrmSiteProductLeft].Form![ComboProductID] = 4
Then
Me.lbl_4.Caption = 9
End Sub
I'm confused: what do you want to see on the mainform if there are 10 records
in the subform's recordsource, with four with 1 in the combo, three with 2,
two with 3 and one with 4?

A combo box can only have one value (well, unless it's a multiselect) but a
subform can have many records. What exactly are you trying to accomplish by
displaying this data redundantly (since the user can just presumably look at
the subform and see what products are there)?
--

John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/For...-US/accessdev/
http://social.answers.microsoft.com/.../en-US/addbuz/
and see also http://www.utteraccess.com

Reply With Quote
  #3  
Old   
bobdydd
 
Posts: n/a

Default Re: Alter Report Captions from a Subform - 06-22-2011 , 03:20 AM



Hi

Thanks for the reply
The Database is for a Vending Machine operator
who has 12 different Products available to
leave at each of the vending machine sites

Each site can only take 9 choices of Product
And each choice of product = 9 items left on
sitehence the caption = 9

This Report is for the vending roundsman to
print out and take on his rounds and manually
write on the paper how many have been sold.

The data showing which Products have been
left on the previous visit, are on the
underlying subform

The result on the report should look something
like this:

Site: Jones the Butchers
Address: 1 High Street, Romford, Essex RM1 1FT
Tel # 01111 111222

Products Left at site last visit

Chocolate Bars 9
Peanut Bars 9
Peppermint Bars 9
Honeycombe Bars 0
Raisin Bars 9
Chocolate wraps 0
Candy Fizz 9
Whirlygigs 9
CHocolate Balls 0
Candy Balls 9
Apricot Bars 9
Maltesers 9

Reply With Quote
  #4  
Old   
John Spencer
 
Posts: n/a

Default Re: Alter Report Captions from a Subform - 06-22-2011 , 08:12 AM



You would have to execute the code in the format or print event of the section
containing the label caption you wanted to change.

I wonder why you are using a sub-form in a report. As far as I can tell you
should be able to use the report header or group header for the company info
and the detail lines for the information you are currently printing using the
sub-form.

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

On 6/22/2011 4:20 AM, bobdydd wrote:
Quote:
Hi

Thanks for the reply
The Database is for a Vending Machine operator
who has 12 different Products available to
leave at each of the vending machine sites

Each site can only take 9 choices of Product
And each choice of product = 9 items left on
sitehence the caption = 9

This Report is for the vending roundsman to
print out and take on his rounds and manually
write on the paper how many have been sold.

The data showing which Products have been
left on the previous visit, are on the
underlying subform

The result on the report should look something
like this:

Site: Jones the Butchers
Address: 1 High Street, Romford, Essex RM1 1FT
Tel # 01111 111222

Products Left at site last visit

Chocolate Bars 9
Peanut Bars 9
Peppermint Bars 9
Honeycombe Bars 0
Raisin Bars 9
Chocolate wraps 0
Candy Fizz 9
Whirlygigs 9
CHocolate Balls 0
Candy Balls 9
Apricot Bars 9
Maltesers 9

Reply With Quote
Reply




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 On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.