Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Import a Picture?

0 views
Skip to first unread message

Chris S. Stewart

unread,
Oct 14, 1999, 3:00:00 AM10/14/99
to
Hia..

I am working on a DB and the user want to be able to have a picture of
person attached or linked to the person's record. That is not a problem...
But......

Is there a way, while filling out a form to import the picture Without
having to go and search for it..?? IE: have a button that says "Have
Picture?" if clicked, it will automatically go to the specified directory
and look for a picture without having to go through the import or paste
part..?? Let's say the Dir will be c:\pics and the file/picture extension
will be either Jpg or Pcx....

I figure there is an easy way of doing this..!!

--
Thanks,

Chris

stew...@cyberstation.net

Joe Fallon

unread,
Oct 14, 1999, 3:00:00 AM10/14/99
to

Use an unbound image frame named: ImageFrame and add a field to your table
called ImagePath.

If the picture is named after the key field (e.g. EmployeeID.jpg -
12345.jpg) then you can have the path field in using a check box and some
code:
Me![ImagePath] = "c:\pics\12345.jpg"

In the OnCurrent event (every time you change to a different record) of your
form use this code:

Private Sub Form_Current()
On Error GoTo Err_Form_Current

If IsNull(Me![ImagePath]) Then
Me![ImageFrame].Picture = "c:\msaccess.jpg" 'any old std jpg for
when there is no associated picture
Else
Me![ImageFrame].Picture = Me![ImagePath]
End If

Exit_Form_Current:
Exit Sub

Err_Form_Current:
Select Case Err.Number
Case 2220
'ignore the Can't Load Image error
Case Else
MsgBox ("Error # " & Str(Err.Number) & " was generated by " &
Err.Source & Chr(13) & Err.Description)
Resume Exit_Form_Current
End Select

End Sub


BTW, the image takes a second or two to load. This process can get very
annoying after a while.
I used the Tab control to "hide" the image on a different "page".
I also moved the code to the OnGotFocus event of the ImagePath text box.
This way the only time the picture loads is when the user clicks the tab to
see it!
--
HTH
Joe
Check out Dev Ashish's web site for answers to common questions
http://www.mvps.org/access/

Chris S. Stewart <stew...@cyberstation.net> wrote in message
news:#kkw3#jF$GA.249@cppssbbsa05...

0 new messages