Resize image box on rpt (1 Viewer)

oxicottin

Learning by pecking away....
Local time
Today, 15:42
Joined
Jun 26, 2007
Messages
856
Hello, I have a continious report that shows 3 text boxes (txtHazardAvoidance, txtHazards and txtJobStep) and an image box named (imgJobStep) on a reports detail section. The row also has a hidden ID text box named (txtJobStepID) and a hidden box named (txtUnboundImagePath) and thats how the imgJobStep gets its image from that box and if no image path then no image.

What I wanted to do is, its taking up to much room to just have all the boxes at 1.125" height and if there is no image the box stays the same size. I want to be able to colaps the box along with the text boxes to the same height. Is this possible and if so how?

Thanks!
Chad
 

scalextric59

Registered User.
Local time
Today, 12:42
Joined
Dec 20, 2008
Messages
87
If there is no image path: on the detail format, resize you image box to the row height and set the visible property to false
 

oxicottin

Learning by pecking away....
Local time
Today, 15:42
Joined
Jun 26, 2007
Messages
856
How would I do it that way because some rows have images and text and some just have text and no image. I tried to use twips to set a heigh and width but it does it for all image boxes because its a continious form. I do have an IDJobStep for each row though.
 

boblarson

Smeghead
Local time
Today, 12:42
Joined
Jan 12, 2001
Messages
32,059
How would I do it that way because some rows have images and text and some just have text and no image. I tried to use twips to set a heigh and width but it does it for all image boxes because its a continious form. I do have an IDJobStep for each row though.

(you wrote first that it was a report and now say form - which is it as it makes quite a lot of difference?)

In a report you can use the On Format event of the detail section to set things visible or not based on criteria (as mentioned by scalextric59).

A continuous form doesn't have that capability.
 

Simon_MT

Registered User.
Local time
Today, 20:42
Joined
Feb 26, 2007
Messages
2,177
Here's a Function that does the trick on any Report or Form:

Code:
Function GetPicture()

Dim FullPath As String

    With CodeContextObject
        FullPath = .[Image File]

        If Dir([FullPath]) <> Empty Then
            .[ImageControl].Visible = True
            .[ImageControl].Picture = FullPath
        Else
            .[ImageControl].Visible = False
        End If
    End With

End Function

All you have to do is set the control to invisible if no file is found.

Simon
 

oxicottin

Learning by pecking away....
Local time
Today, 15:42
Joined
Jun 26, 2007
Messages
856
Sorry Bob I know it makes a diference I wrote the wrong thing :eek: Simon_MT I will try the code and see it it works for me.... Thanks!

Its a report :D
 

oxicottin

Learning by pecking away....
Local time
Today, 15:42
Joined
Jun 26, 2007
Messages
856
Ok my code works for the text boxes great and it also works for the img box (imgJobStep) BUT only to enlarge it, it wont shrink the height for some reason. How can I fix that?

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

If DCount("[JobStepID]", "tblJobSteps", "[ImagePath]=""" & txtImagePath & """") > 0 Then

 Me.imgJobStep.Height = 1470 'Enlarge the image box
  Me.txtHazardAvoidance.Height = 1570
   Me.txtHazards.Height = 1570
    Me.txtJobStep.Height = 1570
   Else
  Me.imgJobStep.Height = 800 'Make image box smaller
   Me.txtHazardAvoidance.Height = 800
    Me.txtHazards.Height = 800
     Me.txtJobStep.Height = 800
   End If
End Sub
 

boblarson

Smeghead
Local time
Today, 12:42
Joined
Jan 12, 2001
Messages
32,059
Make sure the Detail Section's CAN SHRINK property (as well as the controls in your details section are set to YES.
 

oxicottin

Learning by pecking away....
Local time
Today, 15:42
Joined
Jun 26, 2007
Messages
856
Bob the detail is set to can shrink and im still getting the same results. In the image provided the txt boxes have a gap between them because its not letting the image box shrink if there is no image. Everything worked for the first two rows then the imaged box didnt shrink. Any Ideas?
 

Attachments

  • image.JPG
    image.JPG
    47.6 KB · Views: 119

boblarson

Smeghead
Local time
Today, 12:42
Joined
Jan 12, 2001
Messages
32,059
So you set ALL of the controls to Can Shrink YES and the image control is NULL when no image is there or is it an empty string?

Also, you shouldn't be setting the heights if the control is empty.
 

oxicottin

Learning by pecking away....
Local time
Today, 15:42
Joined
Jun 26, 2007
Messages
856
The images (imgJobStep) control source is =[txtUnboundImagePath] which is a text control and if there isnt any text which is a link to the image then there is no image in the imgJobStep.

Gota punch out check back tomorrow.... :p
 
Last edited:

Users who are viewing this thread

Top Bottom