Onactivate event and popup behaviour in reports

G

Guest

I have a on activate event on my report filling a report field when the
report is shown in preview mode.
This did work fine until i changed the report property popup to yes (this
was necessary because the report preview is opened from a modal/pop-up form
and without poping up the report it goes behind the calling form).
And surprise....the on activate event in the report is no longer executed.

Does anyone know how to avoid this?
thanks for any help
 
G

Guest

Try and use the OnOpen event of the report to assign the values instead of
the OnActivate
 
G

Guest

Thank you for awnsering,
no, i did try that but it gives me a runtime error:
'you can't assign a value to this object'.

and the object is an unbound text box [Text58] in the report.

any other ideas?
 
G

Guest

If you wrote
Me.FieldName.Value = Value
change it to
Me.FieldName = Value

If that not the case, can you van post the code you are using
--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck



Rli said:
Thank you for awnsering,
no, i did try that but it gives me a runtime error:
'you can't assign a value to this object'.

and the object is an unbound text box [Text58] in the report.

any other ideas?

Ofer said:
Try and use the OnOpen event of the report to assign the values instead of
the OnActivate
--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck
 
G

Guest

Sorry, i don't think that's the problem. The code i wrote in the OnActivate
event is as follows:

Dim db As DAO.Database
Dim rsd As DAO.Recordset
Set db = CurrentDb
Set rsd = db.OpenRecordset("LIBELLE")
MsgBox "Check to see if i pass here"
Do While Not rsd.EOF
If Left(rsd.Fields("lib texte"), 17) = "Rédaction de bail" Then
[Text58] = rsd.Fields("lib montant") & " € TTC"
End If
rsd.MoveNext
Loop
rsd.Close
Set rsd = Nothing
Set db = Nothing

When the report is opened without the popup property set to YES than this
code is executed correctly. When popup property=NO then not even the MsgBox
is displayed. So it isn't even executed......just because of the pop up
property.
???


Ofer said:
If you wrote
Me.FieldName.Value = Value
change it to
Me.FieldName = Value

If that not the case, can you van post the code you are using
--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck



Rli said:
Thank you for awnsering,
no, i did try that but it gives me a runtime error:
'you can't assign a value to this object'.

and the object is an unbound text box [Text58] in the report.

any other ideas?

Ofer said:
Try and use the OnOpen event of the report to assign the values instead of
the OnActivate
--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck



:

I have a on activate event on my report filling a report field when the
report is shown in preview mode.
This did work fine until i changed the report property popup to yes (this
was necessary because the report preview is opened from a modal/pop-up form
and without poping up the report it goes behind the calling form).
And surprise....the on activate event in the report is no longer executed.

Does anyone know how to avoid this?
thanks for any help
 
M

Marshall Barton

Rli said:
I have a on activate event on my report filling a report field when the
report is shown in preview mode.
This did work fine until i changed the report property popup to yes (this
was necessary because the report preview is opened from a modal/pop-up form
and without poping up the report it goes behind the calling form).
And surprise....the on activate event in the report is no longer executed.


Well, that's bad news. O hadn't been aware that the
activate event and popup interacted like that.

If you want to see the value when the report is opened for
printing, then use the format event of the section
containing the control.

Alternatively, if that's too big a performance hit, use the
Open event, but set the control's ControlSource property
instead of the Value property. E.g. instead of using:
[Text58] = rsd.Fields("lib montant") & " € TTC"
use this:
[Text58].ControlSource = "=""" & rsd.Fields("lib montant")
& " € TTC"""

If you do not want to see that value when the report is
printed, then I think you're stuck. The Activate event is
the only way I know to distinguish between previewing and
printing a report.
 
G

Guest

That's very good Marshall,
Moving the code to the on open event and changing it to
[Text58].ControlSource = "=""" & rsd.Fields("lib montant") & " € TTC"""
works perfectly with the report preview popping up.


Thanks a lot....

Marshall Barton said:
Rli said:
I have a on activate event on my report filling a report field when the
report is shown in preview mode.
This did work fine until i changed the report property popup to yes (this
was necessary because the report preview is opened from a modal/pop-up form
and without poping up the report it goes behind the calling form).
And surprise....the on activate event in the report is no longer executed.


Well, that's bad news. O hadn't been aware that the
activate event and popup interacted like that.

If you want to see the value when the report is opened for
printing, then use the format event of the section
containing the control.

Alternatively, if that's too big a performance hit, use the
Open event, but set the control's ControlSource property
instead of the Value property. E.g. instead of using:
[Text58] = rsd.Fields("lib montant") & " € TTC"
use this:
[Text58].ControlSource = "=""" & rsd.Fields("lib montant")
& " € TTC"""

If you do not want to see that value when the report is
printed, then I think you're stuck. The Activate event is
the only way I know to distinguish between previewing and
printing a report.
 

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