Report_Page Event Only starts on page2

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
 
M

Marshall Barton

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.
 

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