Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adjusting Report spacing when some pictures are involved 1

Status
Not open for further replies.

puforee

Technical User
Oct 6, 2006
741
0
0
US
I have a DB that contains questions for students. Some of the questions have pictures as part of the question. I have built a report showing what I need but I have spacing issue.

The Picture object dose NOT have a "can grow", or "can shrink" property so I can't shink it down so the questions without pictures occupy a smaller area than the questions with pictures. The report may contain many questions and I need some way to automatically shrink the space between them if there is no picture. We do not want to have just one question per page.

Can some one help?
 
Duane- I answered this an hour ago but not I find it did not post.

So..Yes each question is a record.

Currently I have it set so the picture shows below the question...has to be there.

Thanks,
 
I would create a duplicate detail section by making a group footer based on the primary key of the table. You can then cancel the rendering of this section in the On Format event if there is no picture.

Duane
Hook'D on Access
MS Access MVP
 
OK...I set Question_ID to autonumber. I created a grouping on question_ID. I placed the "Image" frame in the question_Id group footer.
I select the Question_ID footer and the On Format event.

Code for the event:
Code:
Private Sub GroupFooter2_Format(Cancel As Integer, FormatCount As Integer)
    If Me.Image Is "" Then
    MsgBox "No Picture"
    DoCmd.CancelEvent
End Sub

I used the CancelEvent because it was the only cancel showing.
This does not work. So, when you say cancel the rendering...how would I do that?

Thanks,
 
Is Image a bound control in your report section?
Do you get a msgbox pop up?
If Image is a field, what is its data type?
Where is your "End If"?

If Image is a text box bound to the path of a picture and it might be empty, I would try:
Code:
Private Sub GroupFooter2_Format(Cancel As Integer, FormatCount As Integer)
    Cancel = IsNull(Me.Image)
End Sub

Duane
Hook'D on Access
MS Access MVP
 
Duh End if. Silly me.

Image is a picture frame that has its Control Source set to Graphic. Graphic is a text field in the table with the link to the picture stored in another folder.
No message popup.

Ok, I entered your suggested code for the QuestionID Footer On Format Event. Just like you wrote it above.
I did not work. The first question does not have a picture...but the large space where the picture would show is still showing. The second quest that does have a
picture shows as it should. So, we still have not removed the large space present in the QuestionID Footer.

Can you detect what I may be doing wrong.
 
Add a text box [txtGraphic] to the section and set its control source to [Graphic].

Code:
Private Sub GroupFooter2_Format(Cancel As Integer, FormatCount As Integer)
    Cancel = IsNull(Me.txtGraphic)
End Sub
or
Code:
Private Sub GroupFooter2_Format(Cancel As Integer, FormatCount As Integer)
    Cancel = Len(Me.txtGraphic & "") = 0
End Sub


Duane
Hook'D on Access
MS Access MVP
 
We are not there yet.
I entered both of your codes...one at a time of course. I also placed the "Graphic" control in the QuestionID Footer area. I changed your code to just Graphic not txtGraphic.

I ran it with both codes. The large space (QuestionID Footer) still shows for the Question without a picture/graphic.

I also put a temporary control in the QuestinID Footer to show the length of the Graphic control. The Question without a graphic is blank. The question with the graphic shows 83 characters.

Am only using your one line code and nothing else...no If or anything.

Thanks,

 
It works exactly as expected for me in a test database. Are you viewing the "Print Preview" or "Report View"? Code doesn't run in the Report View.

This is my code:
Code:
Private Sub GroupFooter1_Format(Cancel As Integer, FormatCount As Integer)
    Cancel = IsNull(Me.graphic)
End Sub

Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top