Dynamic report header

  • Thread starter Thread starter Vsn
  • Start date Start date
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
 
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
 
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
 
Back
Top