Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...you guys have given us a way of asking a question and getting some very timely feedback from other users so we don't have to re-invent the wheel time and again..."

Geography

Where in the world do Tek-Tips members come from?

Can A "Can Shrink" Property Be Coded for an Attachment Data Type Field

Bill6868 (TechnicalUser)
21 Dec 11 9:24
On my report I have an Attachment Data Type table field which contains a .jpg photo.  If there is no photo for the record I'd like the report to "shrink" this field so that the following text fields can move up on the report.

The "can shrink" property is not available with the attachment data type property options.  Could this be done in some other way or VBA code?

Any suggestions would be much appreciated.
lameid (Programmer)
21 Dec 11 9:45
I have not  used the attachment datatype but some initial thoughts...

The idea that seems easiest to implement is to put the picture in a sub report whose record source only has records that have pictures.  Then when there is no picture, there is no record and nothing is displayed.

Alternatively, you could try setting the height of the picture control to 0 or appropriate default height in the section's On Format event based on whether there is data in it.  

The first is method may be more intuitive but because it is using a sub-report which is more resource intensive (slower).  Obviously do not include the picture field in your record source of the main report if using this method.

 
MajP (TechnicalUser)
21 Dec 11 10:54
You can control this yourself pretty easily

CODE

Option Compare Database
Option Explicit
Private mAttachHght As Long
Private mAttachTop As Long
Private mFieldTop As Long
Private mDetailHght As Long

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
'count attachments
If Me.attch.AttachmentCount = 0 Then
  Me.attch.Height = 0
  MoveUp
Else
  Me.attch.Height = mAttachHght
  MoveDown
End If
End Sub

Private Sub Report_Load()
  'save heights and top locations
  mAttachHght = Me.attch.Height
  mAttachTop = Me.attch.Top
  mFieldTop = Me.TextFieldTwo.Top
  mDetailHght = Me.Detail.Height
End Sub

Private Sub MoveUp()
  'Move one or more controls to new location
  'Shrink detail section
  Me.TextFieldTwo.Top = mAttachTop
  'once you move all your controls determine the new height
  'Leave that to you to work, I will hard code. You can basically add the heights of
  'the moved controls and any space in between.
  Me.Detail.Height = Me.TextFieldTwo.Height + 0.25
End Sub
Private Sub MoveDown()
  'Move back to original height
  Me.TextFieldTwo.Top = mFieldTop
  Me.Detail.Height = mDetailHght
End Sub

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close