Photo in a form

jmart34

New member
Local time
Today, 14:43
Joined
Aug 26, 2004
Messages
5
Hi,

How would I use the value in a field to identify the file name for an image on a form.

In other words, I have a form with these fields - ID#, Name, Address, etc. I want to put the persons photo on the form also. The name of the JPG file for each persons photo is his/her ID#.jpg.

Any help would be greatly appreciated.
 
well this is what i am doing presently

1. create an image fram on your form with any image.
2. put the following function in the declare section of your form

Function setImagePath()
Dim strImagePath As String
On Error GoTo PictureNotAvailable
strImagePath = Me.ImagePath
Me.ImageFrame.Picture = strImagePath
Exit Function
PictureNotAvailable:
strImagePath = "C:\My Documents\YourPicName.bmp"
Me.ImageFrame.Picture = strImagePath
End Function

3.Create an Textbox in by the name ImagePath
4. on the OnDoubleClick Event of you image frame put the following code

Dim strFilter As String
Dim lngFlags As Long
Dim varFileName As Variant

strFilter = "Bitmap Files(*.bmp)" & vbNullChar & "*.bmp" & vbNullChar & "Bitmap Files(*.bmp)" & vbNullChar & "*.bmp"

lngFlags = tscFNPathMustExist Or tscFNFileMustExist _
Or tscFNHideReadOnly

varFileName = tsGetFileFromUser( _
fOpenFile:=True, _
strFilter:=strFilter, _
rlngflags:=lngFlags, _
strDialogTitle:="Please choose a file...")

If IsNull(varFileName) Then
Else
Me![ImagePath] = varFileName
End If

5. on the OnCurrent Event of you form Put the folloiwng
=setImagePath()

now what thiswill do is that when you double click you image fram it will open a dialog box to chose you image. when chosen the path of the picture is recorded in the ImagePath Textbox and becauseof the oncurrent event the image is shown in the imageframe.

i believe many good Programmer and Gurus of access will give you advice to store the picture in the form itself, but personally i believe it is not a good practice and furthermore it efects the performance of the form.

Hope this helps you.
 
Thanks Mohammada,

If I want to automaticlly get the image file name from the content in the ID# field rather then have the user double click and imput it how would I do that?

Thanks for your help.
 
well tobe honest i really dont know, or i have tried yet. you have given somthing to work out. i will try to do it and let you know (Sorry for Disappointment)
 
Update ImagePath

You could try to add to the AfterUpdate and OnChange Events of the ID control the code

If notNull(Me.ID) then
Me.ImagePath = Me.ID &".jpg"
End if

Or better to create a sub and call it from those events.
 
Update ImagePath

You could try to add to the AfterUpdate and OnChange Events of the ID control the code

If notNull(Me.ID) then
Me.ImagePath = Me.ID &".jpg"
End if

Or better to create a sub and call it from those events.
 

Users who are viewing this thread

Back
Top Bottom