picture viewable on the form not open in default pic viewer

R

reservedbcreater

on a survey entry form i want u to be able to enter in a entry with a
picture of a house to show. i can only find a way to get it so that when u
click on it the picture opens in a different window(default picture
viewer), i want it to be open, viewable on the form.
what do i do, thanks...
 
R

reservedbcreater

1) Store the pictures (in this case JPEGs) in the same directory as the
database. 2) Store the appropriate picture name in the table. 3)
Programmatically set the .Picture property of an Image Box to the
appropriate file in the On Current event of the form.

ok so 3)how do i do that???????
 
R

Roger Carlson

You do that with code. If you look at the form in Design view and look at
the code module, the pertinent code is this:

'---------------------
Private Sub Form_Activate()
'find the path of the current database
'which is where the jpegs are stored
pathname = CurrentProject.Path
End Sub
'---------------------
Private Sub Form_Current()
On Error GoTo Err_cmdClose_Click
'set the picture path
Me.ImgStock.Picture = pathname & "\" & Me.txtStockGraph
Exit_cmdClose_Click:
Exit Sub
Err_cmdClose_Click:
If Err.Number = 2220 Then 'can't find the file
Resume Next
Else
MsgBox Err.Description
Resume Exit_cmdClose_Click
End If
End Sub
'---------------------

Most of that is error trapping (important!) but the vital code is this:
pathname = CurrentProject.Path
and
Me.ImgStock.Picture = pathname & "\" & Me.txtStockGraph

--
--Roger Carlson
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L
 
R

reservedbcreater

hey i need help
C:\Documents and Settings\adamd\My Documents\My Pictures\2005-01 (Jan)\ is
the pathname but it doesnt work when i insert it where u said pathname
 
R

Roger Carlson

My sample assumes the path is the same as where the database resides.
That's what this code is for:

Private Sub Form_Activate()
'find the path of the current database
'which is where the jpegs are stored
pathname = CurrentProject.Path
End Sub

If you want the path somewhere else, assign it like this:

Private Sub Form_Activate()
'find the path of the current database
'which is where the jpegs are stored
pathname = "C:\Documents and Settings\adamd\My Documents\My
Pictures\2005-01 (Jan)\ "
End Sub

--
--Roger Carlson
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L
 

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