Displaying And Scaling An Image From A URL On A Form, Access 2007

Lateral

Registered User.
Local time
Yesterday, 19:28
Joined
Aug 28, 2013
Messages
388
Hi guys,

I'm a newbie and have been having a great time building and customising a database application and would like to do the following. I am using Access 2007.

I have an application that keeps track of automotive parts and accessories.

I have a table called "PARTS" that contains information about the various parts such as "part_name", "part_id", "price" etc.

I also have a website/shop that displays these various parts and also has an image of each part.

I have managed to incorporate Microsoft Web Browser ActiveX functionality within the app so that when I scroll through the Parts table using the PartsForm, it automatically "reads" the URL from a field in the Parts table called "ImageURL" and displays it in the Microsoft Web Browser ActiveX browser window...this works great.

The only problem I have is that many of the images are too big to fit within the browser's display window.

I tried to find a way to scale the images but can't find anything.

Does anybody know how I can do this???

Thanks for any help you can provide.

Thanks

Best Regards
Greg
 
Thanks for the link mate but it is trying to get me to provide my credit card info for a "so called" 30 day free trial..... Do you have the actual answer?
 
That's weird, because I got the full text from google (but get the same result as you when I click on the link I provided).

google
access 2007 web browser auto scale image

and pick item 4 or 5 - the first post from experts-exchnage. When I do this I see the full text.
 
Thanks mate, I'll give it a try and let you know....
 
I think this one is going to be above my pay scale :)
 
A raise would seem in order then :D
 
Show me the code that displays the picture (and the surrounding code - entire subroutine/function calls please, no snippets). I just might be able to push you the right way towards a raise - but no promises.
 
Hi Spikepl

Here is the code that is connected to the form:

Private Sub Form_Current()
DoCmd.SetWarnings False

Me!WebShopImage.Navigate (Me!Text45)

DoCmd.SetWarnings True

End Sub
 
You need to copy some code into a standard module: http://support2.microsoft.com/default.aspx?scid=kb;en-us;949


Code:
Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, _
  ByVal hdc As Long) As Long
Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, _
  ByVal nIndex As Long) As Long

Const HWND_DESKTOP As Long = 0
Const LOGPIXELSX As Long = 88
Const LOGPIXELSY As Long = 90

'--------------------------------------------------
Function TwipsPerPixelX() As Single
'--------------------------------------------------
'Returns the width of a pixel, in twips.
'--------------------------------------------------
  Dim lngDC As Long
  lngDC = GetDC(HWND_DESKTOP)
  TwipsPerPixelX = 1440& / GetDeviceCaps(lngDC, LOGPIXELSX)
  ReleaseDC HWND_DESKTOP, lngDC
End Function

'--------------------------------------------------
Function TwipsPerPixelY() As Single
'--------------------------------------------------
'Returns the height of a pixel, in twips.
'--------------------------------------------------
  Dim lngDC As Long
  lngDC = GetDC(HWND_DESKTOP)
  TwipsPerPixelY = 1440& / GetDeviceCaps(lngDC, LOGPIXELSY)
  ReleaseDC HWND_DESKTOP, lngDC
End Function

and then use the following subroutine to display (substitute the name of the webbrowser control to yours)

Code:
Private Sub DisplayPicture(PicturePath As String)
Dim s$, w$
Me.wbbPic.Navigate "about:blank"
DoEvents
w = Me.wbbPic.Width / TwipsPerPixelY - 40
Me.wbbPic.Refresh
s = "<html>"
s = s + "<body>"
s = s + "<p><img border=" + """0""" + " src=""" + PicturePath + """ width=""" + w + """ ></p>"
s = s + "<html/>"
s = s + "<body/>"
Me.wbbPic.Document.Write s
End Sub
 
Thanks mate, it's late here and I'll have a play with this in the morning.
 

Users who are viewing this thread

Back
Top Bottom