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!

No space on no image

Status
Not open for further replies.

LARiot

Programmer
Feb 7, 2007
232
Hi. Any help is appreciated.

I'm trying to print a report with some records having images and others not. When no image, there should be no space between records. That is, shrink the detail when no image. I have the following code:

Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
        If IsNull(Me.ImagePath1) And IsNull(Me.ImagePath2) Then
            Me.imgNarrative1.Visible = False
            Me.imgNarrative1.Height = 1
            Me.imgNarrative1.Width = 1
        
            Me.imgNarrative2.Visible = False
            Me.imgNarrative2.Height = 1
            Me.imgNarrative2.Width = 1
            
            Me.Detail.Height = 2160
        
        ElseIf Not IsNull(Me.ImagePath1) Or Not IsNull(Me.ImagePath2) Then
            'n X 1440 (twips per inch) = height and width used
            Me!imgNarrative1.Visible = True
            Me!imgNarrative1.Height = 3360
            Me!imgNarrative1.Width = 3960
            
            Me!imgNarrative2.Visible = True
            Me!imgNarrative2.Height = 3360
            Me!imgNarrative2.Width = 3960
            
            Me.Detail.Height = 4979
        End If
End Sub

It works when the all images in recordset are null or when anything after the first record has image. However if the first record has an image, then the detail height is set at 4979 twips, even though on debug.print of the detail height it said 2160 for no imaged records.

-Nima
"Pluralitas non est ponenda sine necessitate", i.e., "Plurality is not to be posited without necessity" aka K.I.S.S. (Keep It Short and Simple) -- Ockham's Razor
 
Yeah, but you can't do that below the detail section where would go. They're at the bottom of the detail section right now.

-Nima
"Pluralitas non est ponenda sine necessitate", i.e., "Plurality is not to be posited without necessity" aka K.I.S.S. (Keep It Short and Simple) -- Ockham's Razor
 
I'm not sure why you couldn't add one or more group footers under the detail section. Just group on a unique field value and display the footer. This would be similar to a continuation of the detail section.

Duane
Hook'D on Access
MS Access MVP
 
Wouldn't work because sometimes there are multiple records on one page. That was the whole point of suppressing the blank space for records/rows with no image.

-Nima
"Pluralitas non est ponenda sine necessitate", i.e., "Plurality is not to be posited without necessity" aka K.I.S.S. (Keep It Short and Simple) -- Ockham's Razor
 
Do you have one image field per detail record? I'm not sure why you couldn't render the image in a "detail footer" section and use code to cancel the rendering of the section if there is no image.

Duane
Hook'D on Access
MS Access MVP
 
Ther are two images fields per record. How do you add details footer? There's a page footer and there's a report footer, how ever a details footer eludes me.

Also, what do you mean specifically by render?

-Nima
"Pluralitas non est ponenda sine necessitate", i.e., "Plurality is not to be posited without necessity" aka K.I.S.S. (Keep It Short and Simple) -- Ockham's Razor
 
Duane: before I forget, thanks for looking into this.

-Nima
"Pluralitas non est ponenda sine necessitate", i.e., "Plurality is not to be posited without necessity" aka K.I.S.S. (Keep It Short and Simple) -- Ockham's Razor
 
To create a "details footer" section, you would create a new GROUP section on the primary key field or fields. This new section would display/render for every record in your report's record source. You can cancel the printing or formatting of any report section with a little code.

Duane
Hook'D on Access
MS Access MVP
 
Same problem. I'm guessing it has something to do with a page break somewhere. Just can't figure it out.

-Nima
"Pluralitas non est ponenda sine necessitate", i.e., "Plurality is not to be posited without necessity" aka K.I.S.S. (Keep It Short and Simple) -- Ockham's Razor
 
You haven't provided any code so I can see what you tried. I just did a little test where I create a new header and footer section based on the primary key field. I then move almost all my basic controls to the detail header section. I bound a control in the detail section and in the GroupFooter1 that would represent your picture/images. I just tested this and if the field in the section is null, it absolutely doesn't show and doesn't take up any space.

Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    Cancel = IsNull(Me.FieldWithInputMask)
End Sub

Private Sub GroupFooter1_Format(Cancel As Integer, FormatCount As Integer)
    Cancel = IsNull(Me.MemoField)
End Sub

Duane
Hook'D on Access
MS Access MVP
 
This report:

8219362995_54e10497f8.jpg


With this code:

Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

End Sub

Creates this error:

8220476568_253d5446bc_b.jpg


If I blank out the code. It runs without crashing. It looks like I'm grouping it wrong. But I don't know where.

-Thanks

-Nima
"Pluralitas non est ponenda sine necessitate", i.e., "Plurality is not to be posited without necessity" aka K.I.S.S. (Keep It Short and Simple) -- Ockham's Razor
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top