UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Resize Detail Section Based On Control Size, Access 2016    
 
   
B99
post May 20 2020, 04:49 PM
Post#1



Posts: 27
Joined: 15-April 20



Hi All,

This is the first time I've created a report that was not very basic. I have a report where some records will have images and some will not. The images can be any size and I want to change the size of the image control dynamically.

The image control is initially 0.01" x 0.01" and placed on the far left, under the last line of text data in the detail section. Then in the Detail_Format event, I get the width and height of the image, then set the image control width and height to those values. If the record does not have an image, I set the .Picture property to ""; set the width and height properties to 0, and make the control not visible.

Using debug statements, I can see that for each record, the control properties are being updated properly, and the position properties are correct, but the result (in Print Preview) is that the detail section is a static height regardless of whether the record has an image or not. The Can Grow and Can Shrink values are both Yes.

It looks like the detail section is made to be a constant size that will fit the largest image, with about 1/4" padding on the top (the image is moved down from where I put the control). Any records that do not have an image just have a big section of white space.

Should I be using a different event? I've tried the On Print and On Paint events but those were not appropriate. Or is there a way to force the detail section to go back to the default size after each record?

Go to the top of the page
 
theDBguy
post May 20 2020, 04:52 PM
Post#2


UA Moderator
Posts: 78,095
Joined: 19-June 07
From: SunnySandyEggo


Hi. I think you're on the right track. Some events fire and don't fire based on the report's current view. You either don't worry about how it looks on the screen and simply print the report on paper, or duplicate your code in those events that fire in each view. Cheers!

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
B99
post May 20 2020, 05:25 PM
Post#3



Posts: 27
Joined: 15-April 20



Hi theDBguy, thanks for responding. I tried printing to PDF and the result is the same as what it looks like in the Print Preview; I can't figure out how to reset the size of the detail section.

If I run a test where none of the records have images, then it shows up exactly how I want it - which is still resized based on text boxes that can grow. But as soon as I test a record with an image, it's like the detail section becomes static.
Go to the top of the page
 
theDBguy
post May 20 2020, 05:31 PM
Post#4


UA Moderator
Posts: 78,095
Joined: 19-June 07
From: SunnySandyEggo


Hi. If you want us to test it, please post a demo version of your db with sample data.

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
B99
post May 20 2020, 10:24 PM
Post#5



Posts: 27
Joined: 15-April 20



Thanks theDBguy; your help is greatly appreciated.

I found out a little more. The problem seems to be related to the page footer. If I delete the page footer, then the print preview dynamically adjusts the size appropriately. Attached is an example.

I made two hard-coded changes. First, there are only two images in the example and I hard-coded the two records they should print on. Second, the images need to be stored locally so I grabbed two clipart images of different sizes and included them in the zip file. In the Detail_Format procedure, just replace the path name as appropriate for where the images are unzipped.

Right now the image code only fires on the Detail_Format event so if you open the report in Report View, the records are sized properly but there are no images. If you change to Print Preview, you will see the records are now one per page and the images print on their records. (Oddly, the image position is correct; no longer being moved down.)

If you delete the page footer, then the Print Preview works as expected.

Is there something I'm missing on the page footer that is preventing the detail section size from being reset?
Attached File(s)
Attached File  RptImageExample.zip ( 258.08K )Number of downloads: 4
 
Go to the top of the page
 
BruceM
post May 21 2020, 08:33 AM
Post#6


UtterAccess VIP
Posts: 8,110
Joined: 24-May 10
From: Downeast Maine


I had to reduce the image size (divided by 2). Apparently the point size is less on your screen, or something.

I don't have anything definitive, and don't have much time now, but I wonder if it would work to put the images into a subreport, which has Can Grow and Can Shrink properties.
Go to the top of the page
 
B99
post May 21 2020, 08:52 AM
Post#7



Posts: 27
Joined: 15-April 20



Thanks for taking a look BruceM. I didn't think about a subreport. It's not my first choice but might be worth a shot.

QUOTE
I had to reduce the image size (divided by 2). Apparently the point size is less on your screen, or something.

Interesting; the GetDeviceCaps function was supposed to account for different monitor settings for pixels per inch. Something else to add to the list...
Go to the top of the page
 
BruceM
post May 21 2020, 10:59 AM
Post#8


UtterAccess VIP
Posts: 8,110
Joined: 24-May 10
From: Downeast Maine


For images used on a number of reports and not subject to frequent change (a company logo, for instance) I tend to store the image in a subreport rather than linking. For other images I expect an image control in a subreport could be set programatically. I assume, but don't know for sure, that a subreport could grow or shrink depending on the image.
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    26th May 2020 - 08:55 AM