Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Images in reports... 1

Status
Not open for further replies.

MushroomBill

Programmer
Feb 20, 2007
2
GB
Hi Folks.

Sorry Access newbie on the loose...

I'm working on a project to move a number of access databases to a new server. There are a high number of reports - all of which have hard coded links to images - e.g. L:\Logos\abc.jpg.

To make matters more interesting all of the images are also being moved to a new (different) server.

Is there are way of programmatically changing the report definition to modify the image location with the new (UNC) image location. Otherwise its going to be a long and painful task opening each report.....

Any help appreciated.

Thanks

Bill
 
If I were you, I would take this opportunity to store all image file locations in your tables. Then you will maintain data rather than code and expressions.

If you have a lot of this to do and don't want to move your image file names to data, consider purchasing a third party tool to search and replace. There are several good ones that might work for you. Tony Toews has a listing at
Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
The following Sub will enumerate each of the Reports in your database and update all image controls containing the specified old path with the specified new path:
Code:
Public Sub ReportImageUpdate(ByVal sOldPath As String, sNewPath As String)

Dim rpt As Long, rptName As String
Dim ctl As Control

For rpt = 0 To CurrentDb.Containers("Reports").Documents.Count - 1
    rptName = CurrentDb.Containers("Reports").Documents(rpt).Name
    DoCmd.OpenReport rptName, acViewDesign
    With Reports(rptName)
        For Each ctl In .Controls
            If ctl.ControlType = acImage Then
                If InStr(1, ctl.Picture, sOldPath) > 0 Then
                    ctl.Picture = Replace( _
                        CStr(ctl.Picture), _
                        sOldPath, _
                        sNewPath)
                End If
            End If
        Next ctl
    End With
    DoCmd.Close acReport, rptName, acSaveYes
Next rpt

End Sub

Example:
Code:
ReportImageUpdate "L:\Logos\", "\\NewUNCPath\Logos\"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top