make a form that show all images from a folder

eshai

Registered User.
Local time
Today, 11:17
Joined
Jul 14, 2015
Messages
195
hi:

i have to build a form that show images

exempel i need to show all students images from class a or class b and etc'
i need it to it automatically base on the names in the table and query

so if i open form"class a" it well fill at automatically
 

Attachments

  • class imeges.jpg
    class imeges.jpg
    42.5 KB · Views: 85
Hi Eshai,

You can create an unbound main form containing a combo box for class, and a continuous subform based on the students.

The subform would include fields for the name of the student and the image. As far as I know, the subform will not be able to show students in several columns (as in your picture) but only in a vertical list. Because of this, it might be better to have the name to the left of the picture to save space.

You also need to decide if you want to store the images within the database or have them hyperlinked from a file. If there are many, they could make the database larger and slower.

In the After Update event of the combo box you can set a filter for the subform and turn it on, so when you select Class 1, only the Class 1 students show.
 
Hi Eshai,
You also need to decide if you want to store the images within the database show.

thanks for the reply
i already have a folder that contain all images
i need at to be as my picture this is the client requisition
maybe it can be than in ms word or ? :banghead:
 
It can be done in at least 2 ways, both require some programming experience.
1. Create for example. 50 unbound image controls on a form when the form is opened, the control source for each image control is set for the desired photos. Unused image controls are set to invisible.

2. Create a "master" form and using VBA code copy it and put the copy into design view (hidden), create the required number of image controls on the form and the required properties are set for each image control when all image controls are created, the form is saved and afterwards opened in Form view, everything is done using VBA code.
Controls are created in VBA using CreateControl.

As you mention Word as an alternative I'll mention the Report, I think you can do it in a report, by setting it to 4 columns and set the "Column Layout" to "Across, then down".
 
If you already have a list of picture locations (local or URL would do), then a web browser control could do a nice job of it. Just loop through the list and write directly to the window:
Code:
Private Sub Form_Load()
    wb1.Navigate "about:blank"
End Sub
     
Private Sub btnShowAlbum()
    dim rs as recordset
    set rs = currentDB.openrecordset("[I]tblStudentNames_and_PicLocations[/I]") 
              '(or use For Each..In.., if data's in a listbox etc)
    with rs
        .MoveFirst
        wb1.Document.Write "<HTML><TITLE>Class Album</TITLE><BODY><TABLE><TR>"
        do while not .EOF
            wb1.Document.Write "<TD><img src='" & [I]!PicLocation[/I] & "'>"
            wb1.Document.Write "<BR>" & [I]!StudentName[/I] & "</TD>"
            .MoveNext
        loop
        wb1.Document.Write "</TR></TABLE></BODY></HTML>"
        .close
    end with
End Sub
T
he browser control would give you something like (attached) with minimal coding and no need to create or move files.

This method allows for some fun features like fancier formatting, adding individual links to each student's page online grades etc, plus you could save the wb1.text as an HTML file for easy printing/sharing/posting.

 

Attachments

Since you already have a list of image locations, you could quickly produce a nice and customizable result by writing directly to Web Browser Control, sized as large as your form:

Code:
Private Sub Form_Load()
    wb1.Navigate "about:blank"
End Sub
     
Private Sub btnShowAlbum()
    dim rs as recordset
    set rs = currentDB.openrecordset("[I]tblStudentNames_and_PicLocations[/I]") 
                  '(or use For Each..In.. if your data's elsewhere like a listbox etc)
    with rs
        .MoveFirst
        wb1.Document.Write "<HTML><TITLE>Class Album</TITLE><BODY><TABLE><TR>"
        do while not .EOF
            wb1.Document.Write "<TD><img src='" & ![I]PicLocation[/I] & "'>"  '(Can be a local file or a URL)
            wb1.Document.Write "<BR>" & ![I]StudentName[/I] & "</TD>"
            .MoveNext
        loop
        wb1.Document.Write "</TR></TABLE></BODY></HTML>"
        .close
    end with
End Sub
This produces a result something like the attached HTML file. A benefit to this method is that you can easily customize and dynamically re-adjust formatting however you like with tables, links, logos, etc, and as a bonus you could save wb1.Document.Text to a text file as HTML to share, publish, archive, etc.

Note that Access 2013-2016 technically doesn't support Web Browser Controls, however Microsoft provided a quick registry tweak as a workaround: https://support.microsoft.com/en-us/help/2793374/cannot-insert-certain-scriptable-activex-controls-into-office-2013-documents (There's also a copy of the REG file in the attached ZIP.)

 

Attachments

Hooray, my post was mistakenly flagged for moderation due to a known bug, but Uncle Gizmo fixed it up!

...Now after all I went through to get that posted, you better use it. Hahaha totally kidding; slapping together a some code like that is just as much for my own benefit, and something to put away for when I need to look back at what I did.

I know no forum's going to be perfect, but after 4 attempts I was starting to wonder if I was just going crazy!:eek:
 

Attachments

  • wb1-document-write-sample-output.jpg
    wb1-document-write-sample-output.jpg
    82.1 KB · Views: 90
Last edited:

Users who are viewing this thread

Back
Top Bottom