build photo webpage from Access

sehmke

Registered User.
Local time
Today, 19:50
Joined
Sep 2, 2004
Messages
19
Hello people,

Sorry for the lenghty post, I wish to be clear to get a fine answer...

I have a database with all our company's products (more than 2000) and a wide variety of related data (quantities sold, purchase price, ...)

Each of our articles have a photo somewhere on a server. Since I didn't want to blow up my database, I use a function to refer to the photo instead of embedding them into my database.

Each time a form or report is loaded, the function determines the path to the photo (based on article number) so the photos quickly load in an image control. This works very well and I can recommend this to everyone who is currently embedding gigabytes of pictures in their database.

BUT, this seems limited to forms and reports. I wonder if I can do the same with a static HTML page, generated through Access.

HERE IS WHAT I REQUIRE:

My database is stored locally (C: drive). I would like to have on our server (not a webserver!) an HTML file with a drop down field, containing all reference numbers of our articles (populated form my database each time the page is opened in IE). As colleagues select an article from the dropdown and click OK another page should open, displaying related data AND A PHOTO of the article (possibly using the same function as explained above).

MY QUESTION IS SIMPLE:

Can this be achieved??

Thanks for any input.
 
I don't NEED to store the path in a table thanks to that custom function I made (the less data, the better). The function looks at the article number (eg. 12345987) and "builds" the path as being I:\articles\images\12345987.jpg.

The only thing I need to know is how I can build and store an HTML page on the fly which has an image tag in it saying:

<img src="I:\articles\images\12345987.jpg">.

Thanks for your help!
 
Here is a function (run in Access) that will create an HTML page with a dropdown.
It will use Javascript to pop up your pictures in a new, small window.
If you run the resulting HTML doc from anything but a web server, you will probably get a warning about active content in the document.
You are going to have to change some things to get it to work for you. Note the red areas.

Replace C:\\MyFolder\\ with your picture folder path (can be an absolute path on server). NOTE: use \\ in place of \ in this line...it's a Javascript thing.
Replace tblPics with your table name.
Replace PicName & ItemName with your field names.
Replace c:\MyHTMLJSfile.html with the location and name where you want your HTML file to be saved.

Code:
Public Function MakeJSfile()
    Dim MyHTML As String
    Dim MyJS As String
    MyJS = "<script language=javascript> function ShowPic()" _
        & " {var x = ""[COLOR="Red"]C:\\MyFolder\\[/COLOR]""; " & vbCrLf _
        & " var y = document.getElementById('SelectPic').value;" & vbCrLf _
        & "window.open(x + y, 'subWindow', ""height=300,width=300"");}</script>"
    MyHTML = "<html><head>" & MyJS & _
        "</head><body><h2>My List of Things...</h2><select id='SelectPic'>"
    Dim rst As New ADODB.Recordset
    rst.Open "[COLOR="red"]tblPics[/COLOR]", CurrentProject.Connection 
    rst.MoveFirst
    Do While Not rst.EOF
        MyHTML = MyHTML & _
        "<option value='" & rst("[COLOR="red"]PicName[/COLOR]") & "'>" & rst("[COLOR="red"]ItemName[/COLOR]") & "</option>"
        rst.MoveNext
    Loop
    MyHTML = MyHTML & "</select><input type='button' value='Go' " _
        & "onclick='javascript:ShowPic()'></body></html>"

    rst.Close
    Set rst = Nothing
    
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set a = fs.CreateTextFile("[COLOR="red"]c:\MyHTMLJSfile.html[/COLOR]", True)
    a.WriteLine (MyHTML)
    a.Close
    Set fs = Nothing
End Function
I would encourage you to use this as a starting point...it is not meant to be a *complete* solution. There's a lot more you can do with this. :D
 
Last edited:

Users who are viewing this thread

Back
Top Bottom