Report_Page Event Only starts on page2

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

The following code is used to change the picture in an image control based
on a bound text box using the page event in the report. Why does the event
not fire when the first page is displayed. It works for every page except
page 1. On page 1 there is not a picture since I set up the image control
without a picture, but every subseqeunt page has the picture which is named
in the bound text box. I added just a couple of dummy records at the
beginning to get get my first page to be page 2, so my pictures would be
displayed, but I must be missing something about the event. I had tried the
format event and it corrected the problem with no pictures on page 1, but
created other more serious problems with memory when printing. Thanks.


Private Sub Report_page()
Dim strFile As String
Dim strFullPath As String

strFullPath = "C:\Documents and Settings\mcambrose\My
Documents\Ambrose\Photos\" & Me!Text58
strFile = Dir(strFullPath, vbNormal)
On Error GoTo PictureNotAvailable
Me.Image57.Picture = strFullPath
Exit Sub
PictureNotAvailable:
strFile = "C:\Documents and Settings\mcambrose\My
Documents\Ambrose\Photos\ambrose.jpg"
Me.Image57.Picture = strFile

End Sub
 
mcambrose said:
The following code is used to change the picture in an image control based
on a bound text box using the page event in the report. Why does the event
not fire when the first page is displayed. It works for every page except
page 1. On page 1 there is not a picture since I set up the image control
without a picture, but every subseqeunt page has the picture which is named
in the bound text box. I added just a couple of dummy records at the
beginning to get get my first page to be page 2, so my pictures would be
displayed, but I must be missing something about the event. I had tried the
format event and it corrected the problem with no pictures on page 1, but
created other more serious problems with memory when printing. Thanks.


Private Sub Report_page()
Dim strFile As String
Dim strFullPath As String

strFullPath = "C:\Documents and Settings\mcambrose\My
Documents\Ambrose\Photos\" & Me!Text58
strFile = Dir(strFullPath, vbNormal)
On Error GoTo PictureNotAvailable
Me.Image57.Picture = strFullPath
Exit Sub
PictureNotAvailable:
strFile = "C:\Documents and Settings\mcambrose\My
Documents\Ambrose\Photos\ambrose.jpg"
Me.Image57.Picture = strFile

End Sub


The event does fire on the first page, BUT since it fires
after everything else on the page is completely processed,
it is too late to affect a control on the same page. Any
effect it will have on a control will not be seen until the
next page.

You should be using the Format event of the section that
contains the control you want to manipulate.
 
Back
Top