Insert photos

  • Thread starter Thread starter Ixak
  • Start date Start date
I

Ixak

Hello
How could I insert a photo on the database and show it in a form?
I have created an OLE object and try to insert a photo but I don´t success
showing the picture in the form, I can only open it clicking twice and see
the image but not surfing form one record to another.
Thanks for all
 
Option Compare Database
Option Explicit
Dim filename As String, Pathname As String, db As Database
Private Sub Form_Current()
Dim Securitycolor As String
Set db = CurrentDb

On Error GoTo PhotoNone 'If no photo exists this will handle that

filename = db.name
Pathname = Mid(filename, 1, Len(filename) - Len(Dir(filename)))



'-------------------------------------------------------------------------------------------
'I have a frame around the image holder that indicates clearance levels by
color

'-------------------------------------------------------------------------------------------
Securitycolor = SecurityLevel.Value
Select Case Securitycolor
Case "Green"
Me.Frame69.BackColor = 32768
Me.Approved.BackColor = 32768
Case "Yellow"
Me.Frame69.BackColor = 65535
Me.Approved.BackColor = 65535
Case "Red"
Me.Frame69.BackColor = 255
Me.Approved.BackColor = 255
Case "Orange"
Me.Frame69.BackColor = 33023
Me.Approved.BackColor = 33023
Case "Black"
Me.Frame69.BackColor = 0
Me.Approved.BackColor = 0
End Select

'---------------------------------------------
'This line inserts the photo in the form
'---------------------------------------------
Me.imgPHOTO.Picture = Pathname & Me.ID & ".jpg"

Exit Sub

PhotoNone:
'------------------------------------------------------
'If no photo exists a graphic is displayed instead
'-------------------------------------------------------
Me.imgPHOTO.Picture = Pathname & "NoPix.JPG"
End Sub

Hope this helps.
StuD.
 
Sorry, I forgot to mention you need to place the photos in the same folder as
the database. :)

StuD.
 
Back
Top