?
Solved

Report with pictures from a stored folder location

Posted on 2014-07-17
2
Medium Priority
?
216 Views
Last Modified: 2014-07-27
I have a database that includes photo files that are stored not in the database but rather in a defined file folder location.

If you can imagine that you want to inventory the assets of your home.  So lets say you are Client 1 in a tbl Property table.  And you have a picture of the front of your house.  The picture file name is "1-1 House Front.JPG".   The first "1" stands for the client number, the second "1" stands for the Property ID number, and the "House Frount" part of the file name is just to represent the description of the photo.

The picture files get put into the file folder by means of clicking on a label on the property form.  The code to accomplish this is:

Private Sub lblPicturesDataPath_Click()
On Error GoTo Err_lblPicturesDataPath_Click

    Dim strAppName As String
    Dim strClientFolderName As String
    Dim strPropertyFolderName As String

    strClientFolderName = TempVars!strPicturesDataPath & "\" & Trim(Me.txtClientID) & "\"
    strPropertyFolderName = TempVars!strPicturesDataPath & "\" & Trim(Me.txtClientID) & "\" & Trim(Me.txtID) & "\"
    strAppName = "explorer.exe " & strPropertyFolderName

    If Len(Dir(TempVars!strPicturesDataPath, vbDirectory)) = 0 Then
        MkDir (TempVars!strPicturesDataPath)
    End If

    If Len(Dir(strClientFolderName, vbDirectory)) = 0 Then
        MkDir (strClientFolderName)
    End If
    
    If Len(Dir(strPropertyFolderName, vbDirectory)) = 0 Then
        MkDir (strPropertyFolderName)
        MsgBox "Folder has been created on server.  Remember to place image files in this folder."
    End If

    Call Shell(strAppName, 1)

Exit_lblPicturesDataPath_Click:
    Exit Sub

Err_lblPicturesDataPath_Click:
    If Err.Number = 75 Then
        ' probably directory exists but empty
        ' ignore
        Resume Next
    Else
        MsgBox "Unexpected error " & Err.Number & " : " & Err.Description
        Resume Next
    End If

End Sub

Open in new window


Bu now I want to print the picture file on a report but do not know how to call the picture file up to print on the report.

Can anyone help?

By the way I have a setup table that includes "PicturesDataPath" as a field name.

I also have code in a module I've used before that looks like: (but I don't know if this is of any value)

Sub GettingFilesInDir(strPicturesDataPath As String, strProperty As String, strAsset As String, Optional strPictureN As String, Optional extensionStr As String = "*")

    Dim dbs As DAO.Database
    Dim rst As DAO.Recordset
    Dim strFileName As String
    Dim strFullPathName As String

    Set dbs = CurrentDb

    dbs.Execute "DELETE * FROM tblAssetPics"

    Set rst = dbs.OpenRecordset("tblAssetPics")

    If Not Right(strPicturesDataPath, 1) = "\" Then strPicturesDataPath = strPicturesDataPath & "\"
    strFullPathName = strPicturesDataPath & strProperty & "\"

    strFileName = Dir(strFullPathName & "\*." & extensionStr)

    Do While strFileName <> vbNullString
        rst.AddNew
        rst.Fields("Property") = strProperty
        rst.Fields("Asset") = strAsset
        rst.Fields("PictureN") = strPictureN
        rst.Fields("PicturesDataPath") = strFullPathName & strFileName
        rst.Update
        strFileName = Dir
    Loop

    rst.Close

    dbs.Close

    Set rst = Nothing
    Set dbs = Nothing

End Sub

Open in new window

0
Comment
Question by:SteveL13
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 30

Accepted Solution

by:
hnasr earned 2000 total points
ID: 40203294
In your report:
Image control
In Detail format event.
Me!Image1.Picture = Me!ImagePath ' ImagePath holds the image path in the record source of the report

Open in new window

0
 

Author Comment

by:SteveL13
ID: 40211680
I have an image control on the report.  And in the detail format event I have:

Me!AssetImage.Picture = Me!txtPrimaryPictureFile  ' ImagePath holds the image path in the record source of the report

but I get an error:

Runtime error 2465.  DatabaseName can't find the field 'txtPrimaryPictureFile' referred to in your expression.

????
0

Featured Post

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Suggested Courses

777 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