oxicottin
08-26-2010, 12:17 PM
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
08-27-2010, 10:33 AM
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
08-27-2010, 12:39 PM
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
08-27-2010, 01:08 PM
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
08-27-2010, 01:57 PM
Here's a Function that does the trick on any Report or Form:
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
08-27-2010, 02:26 PM
Sorry Bob I know it makes a diference I wrote the wrong thing :o Simon_MT I will try the code and see it it works for me.... Thanks!
Its a report :D
oxicottin
08-31-2010, 07:37 AM
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?
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
08-31-2010, 10:06 AM
Make sure the Detail Section's CAN SHRINK property (as well as the controls in your details section are set to YES.
oxicottin
08-31-2010, 10:17 AM
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?
boblarson
08-31-2010, 10:33 AM
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
08-31-2010, 10:49 AM
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