change label on subFORM in REPORT

H

Henrootje

I have a REPORT with in it a subFORM Now I have this label (lblMonth)
that I want to change. How should I do this? What would be the proper
event to do this? The lblMonth should contain the name of the month as
jan 07 Any ideas?

TIA, Henro
 
G

Guest

What do you mean exactly, do you want the label to change dynamically or
should it just say jan 07. Either way run in code you could try something
like:

me.(subreportname).controlname.caption="jan 07" where controlname is the
name of the label and subreportname is the name of your subreport.

Sometimes it is neccesary to use the full suntaxis like:

Reports![mainreportname]![subreportname]!controlname.caption="your text"

Remember a label has a caption and not a value.

Maurice
 
H

Henrootje

I will try to explain more in detail

I made a form (with some subforms) and I copied it to a report.
Now I ended up with a REPORT (Report1) that has subFORMS (subForm1)

On the subFORM there is a label whose caption should change depending
on a string that is mentioned in the header of the report.
In short the string would be something like: "Corporate Clients 2007 -
Q1"
Using right() I derive the number '1'

the code should be something like:

Dim Q

Q= right(String, 1)

Select Case Q

Case 1
[Code to change the captionof label1 on subform, something like:]
rpt.REPORT1.Forms!subForm1.label1.caption = "some text"
rpt.REPORT1.Forms!subForm1.label2.caption = "some text"
Case 2
[Code to change the captionof label1 on subform, something like:]
rpt.REPORT1.Forms!subForm1.label1.caption = "some text"
rpt.REPORT1.Forms!subForm1.label2.caption = "some text"

End Select.

This should happen when the report is opened.
I find I can not execute any code in the subforms (just will not be
executed :s)
and when using code above I get an error that the object can not be
found which, according my reading about this subject, has something to
do wit an incorrect syntax in the rpt.blablabla
part.............................

Any one has any useful suggestions? Please? I have been at this for a
week, might it be that it is a report with subFORMS that is causing
the trouble????

TIA,

Henro


What do you mean exactly, do you want the label to change dynamically or
should it just say jan 07. Either way run in code you could try something
like:

me.(subreportname).controlname.caption="jan 07" where controlname is the
name of the label and subreportname is the name of your subreport.

Sometimes it is neccesary to use the full suntaxis like:

Reports![mainreportname]![subreportname]!controlname.caption="your text"

Remember a label has a caption and not a value.

Maurice



Henrootje said:
I have a REPORT with in it a subFORM Now I have this label (lblMonth)
that I want to change. How should I do this? What would be the proper
event to do this? The lblMonth should contain the name of the month as
jan 07 Any ideas?
TIA, Henro- Tekst uit oorspronkelijk bericht niet weergeven -

- Tekst uit oorspronkelijk bericht weergeven -
 
G

Guest

You've copied a form onto the report, why don't you try creating a new
subreport instead of the subform. Just create a subreport like the subform.
In code replace the forms references for Report so it could look something
like:

rpt.REPORT1.sRpt1.label1.caption = "some text" -> where srpt1 is the new
subreport you've created.

I don't know if code in the subform will trigger from a report. I do know
that code from a subreport will be triggered. So it could be an object
problem (report mixed with form).

Have a go and let us know if it resolves the issue and otherwise I'll look
into it some more.

Maurice

Henrootje said:
I will try to explain more in detail

I made a form (with some subforms) and I copied it to a report.
Now I ended up with a REPORT (Report1) that has subFORMS (subForm1)

On the subFORM there is a label whose caption should change depending
on a string that is mentioned in the header of the report.
In short the string would be something like: "Corporate Clients 2007 -
Q1"
Using right() I derive the number '1'

the code should be something like:

Dim Q

Q= right(String, 1)

Select Case Q

Case 1
[Code to change the captionof label1 on subform, something like:]
rpt.REPORT1.Forms!subForm1.label1.caption = "some text"
rpt.REPORT1.Forms!subForm1.label2.caption = "some text"
Case 2
[Code to change the captionof label1 on subform, something like:]
rpt.REPORT1.Forms!subForm1.label1.caption = "some text"
rpt.REPORT1.Forms!subForm1.label2.caption = "some text"

End Select.

This should happen when the report is opened.
I find I can not execute any code in the subforms (just will not be
executed :s)
and when using code above I get an error that the object can not be
found which, according my reading about this subject, has something to
do wit an incorrect syntax in the rpt.blablabla
part.............................

Any one has any useful suggestions? Please? I have been at this for a
week, might it be that it is a report with subFORMS that is causing
the trouble????

TIA,

Henro


What do you mean exactly, do you want the label to change dynamically or
should it just say jan 07. Either way run in code you could try something
like:

me.(subreportname).controlname.caption="jan 07" where controlname is the
name of the label and subreportname is the name of your subreport.

Sometimes it is neccesary to use the full suntaxis like:

Reports![mainreportname]![subreportname]!controlname.caption="your text"

Remember a label has a caption and not a value.

Maurice



Henrootje said:
I have a REPORT with in it a subFORM Now I have this label (lblMonth)
that I want to change. How should I do this? What would be the proper
event to do this? The lblMonth should contain the name of the month as
jan 07 Any ideas?
TIA, Henro- Tekst uit oorspronkelijk bericht niet weergeven -

- Tekst uit oorspronkelijk bericht weergeven -
 
H

Henrootje

Creating a subreport instead of a subform made things work!


You've copied a form onto the report, why don't you try creating a new
subreport instead of the subform. Just create a subreport like the subform.
In code replace the forms references for Report so it could look something
like:

rpt.REPORT1.sRpt1.label1.caption = "some text" -> where srpt1 is the new
subreport you've created.

I don't know if code in the subform will trigger from a report. I do know
that code from a subreport will be triggered. So it could be an object
problem (report mixed with form).

Have a go and let us know if it resolves the issue and otherwise I'll look
into it some more.

Maurice

Henrootje said:
I will try to explain more in detail
I made a form (with some subforms) and I copied it to a report.
Now I ended up with a REPORT (Report1) that has subFORMS (subForm1)
On the subFORM there is a label whose caption should change depending
on a string that is mentioned in the header of the report.
In short the string would be something like: "Corporate Clients 2007 -
Q1"
Using right() I derive the number '1'
the code should be something like:
Q= right(String, 1)
Select Case Q
Case 1
[Code to change the captionof label1 on subform, something like:]
rpt.REPORT1.Forms!subForm1.label1.caption = "some text"
rpt.REPORT1.Forms!subForm1.label2.caption = "some text"
Case 2
[Code to change the captionof label1 on subform, something like:]
rpt.REPORT1.Forms!subForm1.label1.caption = "some text"
rpt.REPORT1.Forms!subForm1.label2.caption = "some text"
End Select.
This should happen when the report is opened.
I find I can not execute any code in the subforms (just will not be
executed :s)
and when using code above I get an error that the object can not be
found which, according my reading about this subject, has something to
do wit an incorrect syntax in the rpt.blablabla
part.............................
Any one has any useful suggestions? Please? I have been at this for a
week, might it be that it is a report with subFORMS that is causing
the trouble????

What do you mean exactly, do you want the label to change dynamically or
should it just say jan 07. Either way run in code you could try something
like:
me.(subreportname).controlname.caption="jan 07" where controlname is the
name of the label and subreportname is the name of your subreport.
Sometimes it is neccesary to use the full suntaxis like:
Reports![mainreportname]![subreportname]!controlname.caption="your text"
Remember a label has a caption and not a value.
Maurice
:
I have a REPORT with in it a subFORM Now I have this label (lblMonth)
that I want to change. How should I do this? What would be the proper
event to do this? The lblMonth should contain the name of the month as
jan 07 Any ideas?
TIA, Henro- Tekst uit oorspronkelijk bericht niet weergeven -
- Tekst uit oorspronkelijk bericht weergeven -
 

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