By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,979 Members | 960 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,979 IT Pros & Developers. It's quick & easy.

Web Browser Control Does maintain shape after Resizing.

P: 99
I have an access form with a web browser control and I'm trying to enable it to resize with the form. The code causes the web browser control to shink and grow to the exact dimensions of the form, and leaves space at the top for the rest of the access form...

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Resize()
  2. On Error GoTo ResizeError
  3. 'resize the browser object with the form
  4.  
  5. 'Turn off screen redraw
  6. Dim dblHeaderHeight As Double
  7. dblHeaderHeight = 1.5833
  8.  
  9. Application.Echo False
  10. Me!wbbWebsite.Height = Me.InsideHeight - dblHeaderHeight
  11. Me!wbbWebsite.Width = Me.InsideWidth
  12. 'Turn screen redraw back on
  13. Application.Echo True
  14.  
  15. Exit Sub
  16. ResizeError:
  17.  
  18. ' NB: Turn screen redraw back on if an error occurs!
  19. On Error GoTo 0
  20.  
  21. End Sub
  22.  
The code seems to work fine during the event; it resizes to the exact dimensions. Problem is, after it resizes, if I try to enter text INTO the web browser control, or I click on the record selector at the bottom, the web browser control immediately expands over the entire access form and covers the portion at the top.

Does anyone know how to correct it?
Thanks,
-Adam
Nov 21 '09 #1
Share this Question
Share on Google+
14 Replies


NeoPa
Expert Mod 15k+
P: 31,760
This sounds like something else (not included in your post) is responsible for the resizing. The code as posted clearly works (as you've explained it), so we (You first obviously) need to start looking elsewhere. What about the properties of the form and/or the browser control? Any other code that may be resizing it?
Nov 21 '09 #2

P: 99
Hi NeoPa,

Thanks for the reply. I commented out the following lines. The program does not work, but the problem stopped. The browser does not change shape at all, but when I click on the record selector or add text to a field in the browser, it does not expand and over take the rest of the form.

If I set it back, the problem comes back. It obviously involves the "Application.Echo". Beyond that, I can't figure it out.
Expand|Select|Wrap|Line Numbers
  1. 'Turn off screen redraw
  2. Dim dblHeaderHeight As Double
  3. dblHeaderHeight = 1.5833
  4.  
  5. 'Application.Echo False
  6. 'Me!wbbWebsite.Height = Me.InsideHeight - dblHeaderHeight
  7. 'Me!wbbWebsite.Width = Me.InsideWidth
  8. 'Turn screen redraw back on
  9. 'Application.Echo True
  10.  
  11. Exit Sub
Nov 22 '09 #3

NeoPa
Expert Mod 15k+
P: 31,760
Good logical thinking Adam. Clearly it is related to this code somehow. I'm really not sure I can see how though.

dblHeaderHeight looks a bit suss though. When does it actually show the expected size? I would never expect it to as that value seems to be in something quite different from Twips. Centimetres or inches or something. I would actually expect it to fill up your whole form, or at least so nearly all of it that you wouldn't notice any gap.
Nov 22 '09 #4

ADezii
Expert 5K+
P: 8,692
I'm literally running out the door, but isn't it a matter of measurement. InsideHeight is measured in Twips, so subtracting a dblHeaderHeight of 1.5883 would give you the InsideHeight of the Form - .001 inch (1.5883/1440).
Expand|Select|Wrap|Line Numbers
  1. Me!wbbWebsite.Height = Me.InsideHeight - dblHeaderHeight 
Nov 22 '09 #5

P: 99
Nice Job. You nailed it.

1.5833 * 1440 = 2279.952

when dblHeaderHeight = 2279.952, the code works perfectly.

Odd how it initially worked in inches, but then snapped to the full form the moment you touched it.

Thanks,
Adam
Nov 22 '09 #6

ADezii
Expert 5K+
P: 8,692
@AdamOnAccess
You are quite welcome, Adam.
Nov 22 '09 #7

NeoPa
Expert Mod 15k+
P: 31,760
@NeoPa
I guess you missed this then ;)
Nov 22 '09 #8

P: 99
NeoPa,

I didn't miss it. That "Nailed It" was directed at both of you. :)

Many thanks for your help.

The thing that still puzzles me is the way the error showed up. How come it first adjusted the web browser control in inches and, only after you entered text or clicked the record selector, would it snap over the whole form? How come it didn't cover the entire form immediately? Had it done that, I would have known where to look, but since it came up correctly, I didn't think that value was suspect.

Either way, thanks again for all your help.
-Adam
Nov 22 '09 #9

NeoPa
Expert Mod 15k+
P: 31,760
@AdamOnAccess
My bad Adam. Must have been short on patience that day :)
@AdamOnAccess
Very good question Adam. Again, that's exactly what I was getting at in my earlier response. It may be interesting to see for myself if you have no problem posteing the database. It doesn't need everything if you have sensitive stuff in it. Just enough to illustrate the problem, and some instructions on how to reproduce it. I'll just copy in some instructions for posting databases here :
When attaching your work please follow the following steps first :
  1. Remove anything not relevant to the problem. This is not necessary in all circumstances but some databases can be very bulky and some things do not effect the actual problem at all.
  2. Likewise, not entirely necessary in all cases, but consider saving your database in a version not later than 2003 as many of our experts don't use Access 2007. Largely they don't want to, but some also don't have access to it. Personally I will wait until I'm forced to before using it.
  3. If the process depends on any linked tables then make local copies in your database to replace the linked tables.
  4. If you've done anything in steps 1 to 3 then make sure that the problem you're experiencing is still evident in the updated version.
  5. Compile the database (From the Visual Basic Editor select Debug / Compile {Project Name}).
  6. Compact the database.
  7. Compress the database into a ZIP file.
  8. When posting, scroll down the page and select Manage Attachments (Pressing on that leads you to a page where you can add or remove your attachments. It also lists the maximum file sizes for each of the allowed file types.) and add this new ZIP file.
It's also a good idea to include some instructions that enable us to find the issue you'd like help with. Maybe some instructions of what to select, click on, enter etc that ensures we'll see what you see and have the same problems.
Nov 23 '09 #10

P: 99
Ok NeoPa,

Here it is:

I converted the database to mdb format. I'm on 2007, but the problem still showed up in the mdb version.

To see the error, open the database and open the form "frmBrowser1".

The form will open and execute docmd.Maximize

The Web Browser Control should automatically resize to the full screen, except for the header space above it, which is approximately 1.5 inches.

The Web Browser Control is set to open to the Google home page.

When Google comes up, enter a single character into the Google homepage text box. You should see the web browser control immediately expand and cover the whole form.

The question is, when dblHeaderHeight is set to 1.5833, why would Access first display the control in inches, but then, after you enter text into the control, it immediately converts to twips and expands over the whole form?

P.S.
As you might imagine, I'm very new to this web browser control. Please check my list of events in the property sheet of the web browser control. It only shows 5 possible events. I know there must be more and I don't know how to access them. I tried bringing up the custom property sheet but I got an error: "The operation on the microsoft web browser failed. Ole Server may need to be reinstalled." Any light you can shed on that would also be appreciated.

As Always,
Thanks,
Adam
Attached Files
File Type: zip FunnyBrowser.zip (31.8 KB, 203 views)
Nov 23 '09 #11

NeoPa
Expert Mod 15k+
P: 31,760
Well Adam. I must say I'm equally confused.
  1. The value of Me.wbbWebsite.Height won't display in the dubugger. This makes determining exactly what's going on when, and tying things down, all quite difficult :( I never could work out why the code even appeared to work in the first place.

    BTW I'd code it anyway, as :
    Expand|Select|Wrap|Line Numbers
    1. Me.wbbWebsite.Height = Me.InsideHeight - Me.wbbWebsite.Top
    This is far more intuitive and has the bonus of never requiring to be changed as it will always match exactly.
  2. I too, see the list of events as only five. Bizarre. In the debugger window you can enter new Event Procedures by selecting wbbWebsite from the left-hand ComboBox and the relevant event from the right-hand one. Why these are not all available in the Properties Pane I don't know.
Maybe it's just a weird control. Certainly I saw all the things you describe.
Nov 23 '09 #12

ADezii
Expert 5K+
P: 8,692
It only shows 5 possible events. I know there must be more and I don't know how to access them.
  1. In Form Design View.
  2. View ==> Code.
  3. Select wbbWebsite in the Object Drop Down List in the Upper Left Corner of the Code Window.
  4. In the Drop Down List in the Upper Right Corner, of the Code Window, you will now see more Events than you can handle that are associated with the Web Browser Control.
Nov 23 '09 #13

P: 99
NeoPa,

Yes, your recode is a definite improvement. If I change the layout of the form and the browser control, I won't have to mess with the code at all. Nice!

Interesting side note...

In my property sheet, the TOP property is set at 1.625 (this is in inches).

For the heck of it, I tried this...

Expand|Select|Wrap|Line Numbers
  1. 'Me!wbbWebsite.Height = Me.InsideHeight - Me!wbbWebsite.Top
  2. Debug.Print Me!wbbWebsite.Top
  3.  
...and the debug window showed 2340

Correct me if I'm wrong but I interpret this to mean that Access is always using twips. The application options will display my measurement setting of inches in the property sheet, but ultimately, Access is using twips.

As far as uncovering additional events, I found them in the drop down as you and ADezii described. I've never seen a control with an incomplete property sheet. I didn't no the event would still get picked up if it wasn't listed in the property sheet. Good thing to know.

As far as my coming upon a "weird" browser control... yeah, that would be just like me. :)

Hey, thanks again for all the help.
You too, ADezii,

- Adam
Nov 23 '09 #14

NeoPa
Expert Mod 15k+
P: 31,760
@AdamOnAccess
Thank you. I'm glad I was able to help.
@AdamOnAccess
That's always been my understanding yes. How it shows to you is down to the Regional Settings in your PC I believe.
Nov 23 '09 #15

Post your reply

Sign in to post your reply or Sign up for a free account.