Trying to get subreport to print all pictures in a specified folder

Posted on 2014-08-05
Last Modified: 2014-08-11
I have the following code in an onformat event of a subreport which works fine to print the primary picture file as defined in the record table in an existing report.   But if the specified folder has more than one picture file in it I want the report to print all of the pictures in the subreport for a new report.

Here is the code which is working fine for the current report.  What do I have to do to it to make the new subreport print all of the pictures?

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    Dim strClientFolderName As String
    Dim strPropertyAssetFolderName As String
    Dim strPropertyFolderName As String

    strClientFolderName = TempVars!strPicturesDataPath & "\" & Trim(Me.txtClientTableID) & "\"
    strPropertyFolderName = strClientFolderName & Trim(Me.txtPropertyTableID) & "\"
    strPropertyAssetFolderName = strPropertyFolderName & Trim(Me.txtManualAssetN)

    Me.AssetImage.Picture = strPropertyAssetFolderName & "\" & Me.PrimaryPictureFile

End Sub

Open in new window

Question by:SteveL13
    1 Comment
    LVL 74

    Accepted Solution

    Without any context, is difficult to see what is happening in you code...

    In any event, ...code like this will loop all .jpg images in a folder
    ...So if you need to: "print all of the pictures?"
    ...I am sure you can modify this code to work in yours

    Dim strJPGFileName As String
    strJPGFileName = Dir("C:\YourFolder\*.jpg", vbDirectory)
        While strJPGFileName <> ""
            MsgBox strJPGFileName
            strJPGFileName = Dir


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    In the previous article, Using a Critera Form to Filter Records (, the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
    A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
    Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
    With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now