jcgroove
asked on
Need help with OLE Object auto resize in a report
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!
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!
ASKER
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.
Okay, how about adding the ControlSource via code prior to running Leban's code.
ASKER
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"
The OLE frame on the report is named "OLEAutoResize"
In the report's Open event, can you try adding
Me.OLEAutoResize.ControlSo urce= "DRAWINGS"
before running Leban's routine?
Me.OLEAutoResize.ControlSo
before running Leban's routine?
ASKER
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.
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.
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.
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
ASKER
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?
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?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Me.NameOfControl.SourceDoc
...Lebans code