?
Solved

Need help with OLE Object auto resize in a report

Posted on 2012-08-24
9
Medium Priority
?
345 Views
Last Modified: 2015-03-14
So I've been trying to get the Lebans autoresizeole to work with a report. I've tried to execute the code from the report open, activate, change events with no success. It doesn't work when i open the report or do a print preview. I've even tried to execute the code from the report area format event. I've only been able to get it to work when I open the report and execute it using the double click event.
I can't help but suspect that the code is executed before the object is populated from the data table. That would make sense anyways.
Does anyone have any idea about how I can get this to function the same as with the form? It works perfectly with the form!
0
Comment
Question by:jcgroove
  • 5
  • 4
9 Comments
 
LVL 29

Expert Comment

by:IrogSinta
ID: 38332567
I'm not sure I can help but I'm wondering if your OLE object have a Source Doc?  If so, maybe you can add it by code prior to running Leban's code.

Me.NameOfControl.SourceDoc = "path and file of document"
...Lebans code
0
 

Author Comment

by:jcgroove
ID: 38334177
Thanks for the response. The bitmap that populates the ole object frame that the code effects is stored in the main table with the text data. It isn't from a separate source document.
0
 
LVL 29

Expert Comment

by:IrogSinta
ID: 38334193
Okay, how about adding the ControlSource via code prior to running Leban's code.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:jcgroove
ID: 38337050
I could not figure out the right way to do what you're recommending. The table the report is built from is "Main Question Bank" and the ole table field is "DRAWINGS".
The OLE frame on the report is named "OLEAutoResize"
0
 
LVL 29

Expert Comment

by:IrogSinta
ID: 38337535
In the report's Open event, can you try adding
Me.OLEAutoResize.ControlSource= "DRAWINGS"

before running Leban's routine?
0
 

Author Comment

by:jcgroove
ID: 38338717
Ok I tried what you recommended but it still doesn't work. I was able to get it to work with some bugs by putting it in the detail format section of the report but it only works on print preview not when opening the report.
The problem i have now is that when there is no object in the OLE frame it alerts an error telling me the frame is empty. On the entries with no OLE objects the empty frame fills up the empty space left on that page of the report whereas on entries that do have objects in the OLE frame, the frame correctly resizes to the size of the image.
0
 
LVL 29

Expert Comment

by:IrogSinta
ID: 38339157
Were you trying to get it to work in the Report View?  I don't believe Leban's code can work in that view since Report View only came to being since version 2007.  It definitely would work in Print Preview though.  

You could do a check to skip his code if the frame is empty.
If Not IsNull(Me.OLEAutoResize) then
     Leban's code
End If

Open in new window

0
 

Author Comment

by:jcgroove
ID: 38351536
Sorry for the delay. Here's what I've tried:
I tried to add the if statement to check if the frame was empty. I also added a msgbox to help me see what was going on. With that, it appears the code runs when it formats and when it pops up the print preview. If only records where the object frame is empty are selected, everything works swimmingly. However, if a record with an image in the frame is selected in addition, it appears that the code resizes all the OLE object frames on the report regardless of whether or not there is an image in the OLE frame. So even the empty frames are the same size as the frame with the image in it.
So then I tried to give the empty frames a given size in the "else" portion of the checking for empty if/then statement. This seems to work pretty well with a particularly substantial drawback. The generated report gives each record its own page regardless of the size of the empty frame (50x50). I know it doesn't sound too bad, but that is the primary reason I'm trying to get this functionality to work. To get multiple records (if the OLE frame is empty) on one page and if the frame isn't empty, to resize the frame and continue on.
Any ideas?
0
 
LVL 29

Accepted Solution

by:
IrogSinta earned 780 total points
ID: 38352418
Check to make sure that the CanShrink property of the detail section where your frame is set to true.
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question