Using same picture on many froms

S

StuJol

I have a form called "Setup" where the user can load an image into it using
the following code. (Code is from Northwind Sample Database/Employees Form)

Sub getFileName()
' Displays the Office File Open dialog to choose a file name
' for the current employee record. If the user selects a file
' display it in the image control.
Dim fileName As String
Dim result As Integer
With Application.FileDialog(msoFileDialogFilePicker)
.Title = "Select Company Logo"
.Filters.Add "All Files", "*.*"
.Filters.Add "JPEGs", "*.jpg"
.Filters.Add "Bitmaps", "*.bmp"
.FilterIndex = 3
.AllowMultiSelect = False
.InitialFileName = CurrentProject.Path
result = .Show
If (result <> 0) Then
fileName = Trim(.SelectedItems.Item(1))
Me![ImagePath].Visible = True
Me![ImagePath].SetFocus
Me![ImagePath].Text = fileName
Me![Business Type].SetFocus
Me![ImagePath].Visible = False
End If
End With
End Sub

In my forms Current Event I also have the following code, which is also from
northwind/employees form.

Private Sub Form_Current()
' Display the picture for the current employee record if the image
' exists. If the file name no longer exists or the file name was blank
' for the current employee, set the errormsg label caption to the
' appropriate message.
Dim res As Boolean
Dim fName As String

Path = CurrentProject.Path
On Error Resume Next
errormsg.Visible = False
If Not IsNull(Me!CompanyLogo) Then
res = IsRelative(Me!CompanyLogo)
fName = Me![ImagePath]
If (res = True) Then
fName = Path & "\" & fName
End If

Me![ImageFrame].Picture = fName
showImageFrame
Me.PaintPalette = Me![ImageFrame].ObjectPalette
If (Me![ImageFrame].Picture <> fName) Then
hideImageFrame
errormsg.Caption = "No Company Logo Found, Click Add/Change
to add Logo"
errormsg.Visible = True
End If
Else
hideImageFrame
errormsg.Caption = "Click Add/Change to add Company Logo"
errormsg.Visible = True
End If
End Sub


I have several forms in my database which i want to display the same image
as whats in my form Setup. Ive been experimenting with code but ot jet found
a solution. Can anyone help??
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top