Dynamic report header

V

Vsn

Hi all,

I have done it years ago, but can remember how.......

I would like to change te 'header'an an report dinamicaly. So that i can
open the report from a form using OpenArg with different text each time. I
thought somthing like this:-

Private Sub Report_Open(Cancel As Integer)
Me.txtHeader = Me.OpenArgs
End Sub

I get the error message: You can't aggign a value to this object (Run-time
error -2147352567 (80020009).

How I can I achieve to change the report headers text?

Thax for advice.

Cheers,
Ludovic
 
A

Allen Browne

Report_Open it too early to assign a Value to a bound control. Use the
Format event of the section (Report header? Page header?) to assign the
value.

If you really want to use Report_Open perhaps you could use a label instead
of the text box, and then:
If Me.OpenArgs <> vbNullString Then
Me.[YourLabelNameHere].Caption = Me.OpenArgs
End If
Trouble with that is if you need to use CanGrow.

Another alternative is to assign the Control Source rather than the value:
If Me.OpenArgs <> vbNullString Then
Me.txtHeader.ControlSource = Me.OpenArgs
End If
 
V

Vsn

Allan,

It works perfectly using the Format event.

Private Sub ReportHeader_Format(Cancel As Integer, FormatCount As Integer)
If Me.OpenArgs <> vbNullString Then
Me.lblHeader.Caption = Me.OpenArgs
End If
End Sub


Thanks,
Ludovic

Allen Browne said:
Report_Open it too early to assign a Value to a bound control. Use the
Format event of the section (Report header? Page header?) to assign the
value.

If you really want to use Report_Open perhaps you could use a label
instead of the text box, and then:
If Me.OpenArgs <> vbNullString Then
Me.[YourLabelNameHere].Caption = Me.OpenArgs
End If
Trouble with that is if you need to use CanGrow.

Another alternative is to assign the Control Source rather than the value:
If Me.OpenArgs <> vbNullString Then
Me.txtHeader.ControlSource = Me.OpenArgs
End If

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.


Vsn said:
Hi all,

I have done it years ago, but can remember how.......

I would like to change te 'header'an an report dinamicaly. So that i can
open the report from a form using OpenArg with different text each time.
I thought somthing like this:-

Private Sub Report_Open(Cancel As Integer)
Me.txtHeader = Me.OpenArgs
End Sub

I get the error message: You can't aggign a value to this object
(Run-time error -2147352567 (80020009).

How I can I achieve to change the report headers text?

Thax for advice.

Cheers,
Ludovic
 

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