A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

open picture from on click



 
 
Thread Tools Display Modes
  #1  
Old February 13th, 2006, 11:17 PM posted to microsoft.public.access.gettingstarted
external usenet poster
 
Posts: n/a
Default open picture from on click

Hi

I followed the code done in this post but I'm getting an error message... I
did the following:
1) Added a field in my table, text field, where I placed the filename of my
jpg
2) Added an unbound object frame on my form to display the jpg image and
added the "on click" code below
3) On the form where I placed my unbound object frame, I added the "on
current" code below.
4) Changed the path_name to where I stored my jpg images

Please help...


The simplest way to open just about any document in its default program
is to use something like this:

Application.FollowHyperlink Me.Path_Name & Me.Photo_Name & ".jpg"



On Wed, 21 Dec 2005 11:00:02 -0800, Cioffredi
wrote:

In a form I am pulling photos using the following code.

Private Sub Form_Current()
Dim Path_Name As String
Path_Name = "P:\PR40362\Database Photos\"
On Error Resume Next
imgPicture1.Visible = True
imgPicture1.Picture = [Path_Name] & [Photo_Name] & ".jpg"
'Error message to display if photo not defined
If Err = 2220 Then
imgPicture1.Visible = False
Exit Sub
End If
End Sub

where Photo_Name is a column in the necessary table. Therefore each record
pulls a new photo. What I would like to do is "On Click" have this image act
like a hyperlink and open the image in Microsoft Picture Manager (or whatever
the defualt photo editor is set to). Thanks in advance for any help or
suggestions,

Cioffredi


--
John Nurick [Microsoft Access MVP]

Please respond in the newgroup and not by email.





  #2  
Old February 14th, 2006, 12:57 AM posted to microsoft.public.access.gettingstarted
external usenet poster
 
Posts: n/a
Default open picture from on click

Freeda:

Firstly you should use an Image control not an unbound object frame.
Secondly I would not hard-code the path to the folder in the code. The path
is data and data should only be stored as values at column positions in rows
in tables. So create a one-row table ImageFolder say with a text column
ImagePath and store the path in that. Any time you might change the location
all you need to do is edit this one-row table.

Base your form on a query which includes the table containing the names of
the JPEGs and the ImageFolder table, but do not join the tables. This will
return what's known as the Cartesian product of the tables, which joins every
row of one table to every row of the other. As Image folder only has one row
the ImagePath value will be the same in every row returned by the query.

In the form's Current event procedure you can now assign the path to the
Image control's Picture property:

Dim strFullPath as String

strFullPath = Me.ImagePath & Me.Photo_Name & ".jpg"

' if file doesn't exist exist hide control
If Dir(strFullPath) = "" Then
imgPicture1.Visible = False
Else
' show control and load image
imgPicture1.Visible = True
imgPicture1.Picture = strFullPath
End If

With JPEGs you get a progress message popping up as the file loads. This is
at best annoying, at worst can crash Access if you page too fast through the
records in the form. You can suppress it with the following registry hack:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Graphics
Filters\Import\JPEG\Options]

"ShowProgressDialog"="No"

For a method of suppressing the dialogue by calling the Windows API see the
following link:

http://www.mvps.org/access/api/api0038.htm

Ken Sheridan
Stafford, England

"Freeda" wrote:

Hi

I followed the code done in this post but I'm getting an error message... I
did the following:
1) Added a field in my table, text field, where I placed the filename of my
jpg
2) Added an unbound object frame on my form to display the jpg image and
added the "on click" code below
3) On the form where I placed my unbound object frame, I added the "on
current" code below.
4) Changed the path_name to where I stored my jpg images

Please help...


The simplest way to open just about any document in its default program
is to use something like this:

Application.FollowHyperlink Me.Path_Name & Me.Photo_Name & ".jpg"



On Wed, 21 Dec 2005 11:00:02 -0800, Cioffredi
wrote:

In a form I am pulling photos using the following code.

Private Sub Form_Current()
Dim Path_Name As String
Path_Name = "P:\PR40362\Database Photos\"
On Error Resume Next
imgPicture1.Visible = True
imgPicture1.Picture = [Path_Name] & [Photo_Name] & ".jpg"
'Error message to display if photo not defined
If Err = 2220 Then
imgPicture1.Visible = False
Exit Sub
End If
End Sub

where Photo_Name is a column in the necessary table. Therefore each record
pulls a new photo. What I would like to do is "On Click" have this image act
like a hyperlink and open the image in Microsoft Picture Manager (or whatever
the defualt photo editor is set to). Thanks in advance for any help or
suggestions,

Cioffredi


--
John Nurick [Microsoft Access MVP]

Please respond in the newgroup and not by email.





  #3  
Old February 15th, 2006, 05:49 PM posted to microsoft.public.access.gettingstarted
external usenet poster
 
Posts: n/a
Default open picture from on click

Hi Ken

My query is really an "enhancement" to my existing database. I already have
a form (frmLenders) that links to a table (tblMasterLender). I just want to
add that Image Control to display the jpg image in my frmLenders. I already
added the ImagePath field to tblMasterLender. I changed my unbound object
frame to an image but it doesn't change the jpg image displayed when I click
on a different Lender.

"Ken Sheridan" wrote:

Freeda:

Firstly you should use an Image control not an unbound object frame.
Secondly I would not hard-code the path to the folder in the code. The path
is data and data should only be stored as values at column positions in rows
in tables. So create a one-row table ImageFolder say with a text column
ImagePath and store the path in that. Any time you might change the location
all you need to do is edit this one-row table.

Base your form on a query which includes the table containing the names of
the JPEGs and the ImageFolder table, but do not join the tables. This will
return what's known as the Cartesian product of the tables, which joins every
row of one table to every row of the other. As Image folder only has one row
the ImagePath value will be the same in every row returned by the query.

In the form's Current event procedure you can now assign the path to the
Image control's Picture property:

Dim strFullPath as String

strFullPath = Me.ImagePath & Me.Photo_Name & ".jpg"

' if file doesn't exist exist hide control
If Dir(strFullPath) = "" Then
imgPicture1.Visible = False
Else
' show control and load image
imgPicture1.Visible = True
imgPicture1.Picture = strFullPath
End If

With JPEGs you get a progress message popping up as the file loads. This is
at best annoying, at worst can crash Access if you page too fast through the
records in the form. You can suppress it with the following registry hack:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Graphics
Filters\Import\JPEG\Options]

"ShowProgressDialog"="No"

For a method of suppressing the dialogue by calling the Windows API see the
following link:

http://www.mvps.org/access/api/api0038.htm

Ken Sheridan
Stafford, England

"Freeda" wrote:

Hi

I followed the code done in this post but I'm getting an error message... I
did the following:
1) Added a field in my table, text field, where I placed the filename of my
jpg
2) Added an unbound object frame on my form to display the jpg image and
added the "on click" code below
3) On the form where I placed my unbound object frame, I added the "on
current" code below.
4) Changed the path_name to where I stored my jpg images

Please help...


The simplest way to open just about any document in its default program
is to use something like this:

Application.FollowHyperlink Me.Path_Name & Me.Photo_Name & ".jpg"



On Wed, 21 Dec 2005 11:00:02 -0800, Cioffredi
wrote:

In a form I am pulling photos using the following code.

Private Sub Form_Current()
Dim Path_Name As String
Path_Name = "P:\PR40362\Database Photos\"
On Error Resume Next
imgPicture1.Visible = True
imgPicture1.Picture = [Path_Name] & [Photo_Name] & ".jpg"
'Error message to display if photo not defined
If Err = 2220 Then
imgPicture1.Visible = False
Exit Sub
End If
End Sub

where Photo_Name is a column in the necessary table. Therefore each record
pulls a new photo. What I would like to do is "On Click" have this image act
like a hyperlink and open the image in Microsoft Picture Manager (or whatever
the defualt photo editor is set to). Thanks in advance for any help or
suggestions,

Cioffredi


--
John Nurick [Microsoft Access MVP]

Please respond in the newgroup and not by email.





 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I run two full contact lists and calendars on 1 outlook? janeelman General Discussions 5 April 18th, 2009 04:24 PM
Global replace for "File As" [email protected] Contacts 3 November 19th, 2005 09:55 PM
Protect Workbook vs Worksheet?? Dan B Worksheet Functions 3 November 7th, 2005 09:02 PM
How can I make a button, click on it and open a picture? MStim New Users 1 October 1st, 2005 03:25 AM
RPC over HTTP Outlook and Small Business Server Tomo General Discussion 1 September 5th, 2005 02:44 PM


All times are GMT +1. The time now is 10:54 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.