By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,650 Members | 1,785 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,650 IT Pros & Developers. It's quick & easy.

opening an image viewer

P: n/a
Hi

I have a table which has path names to photos I would like to view. I
would like to open some/any kind of image viewer(Paint) to see the
picture when I click the pathname.

The pictures are mostly scanned newspaper atricles which are too big
to just display on a form so I need the zoom and scroll features.

Im using access 2003

thanks in anticipation
Shumit
Nov 13 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
See help for the Shell statement... that will open another program, and you
can specify "command line parameters", too, so you should be able to open an
image processing program on the file whose path and filename you have
stored.

Larry Linson
Microsoft Access MVP

"Shumit Rehman" <sh**********@hotmail.com> wrote in message
news:3a**************************@posting.google.c om...
Hi

I have a table which has path names to photos I would like to view. I
would like to open some/any kind of image viewer(Paint) to see the
picture when I click the pathname.

The pictures are mostly scanned newspaper atricles which are too big
to just display on a form so I need the zoom and scroll features.

Im using access 2003

thanks in anticipation
Shumit

Nov 13 '05 #2

P: n/a
Hi Shumit,

How about this idea?:

1.) Modify your table so that you store your FilePath string as a Hyperlink.
2.) Design a form based on this modified table
3.) Add an Image Control (Size Mode = Zoom) on this form that will allow you
to "preview" the image as you navigate from record to record.
4.) The file path for the hyperlink could be set using Dev's FileOpenSave
Common Dialog API http://www.mvps.org/access/api/api0001.htm
5.) The hyperlink can be used "dual purpose"...
Clicking on it will open the image in the default viewer assigned for files
of that type,
and if we trim out the "#" signs, it can also be used to set the .Picture
property of the Image control.

If this sounds good, here is the code that you'll need...

****************** Main Module (DB Window) Code ******************
-- I'd suggest pasting this code into the same module as the FileOpenSave
API

'------------------------------------------------------
Function GetGraphic()
' Requires FileOpenSave API code
' from http://www.mvps.org/access/api/api0001.htm

Dim strFilter As String

strFilter = ahtAddFilterItem(strFilter, "TIFF Files (*.tif, *.tiff)",
"*.TIF; *.TIFF")
strFilter = ahtAddFilterItem(strFilter, "JPEG Files (*.jpg, *.jpeg)",
"*.JPG; *.JPEG")
strFilter = ahtAddFilterItem(strFilter, "GIF Files (*.gif)", "*.GIF")
strFilter = ahtAddFilterItem(strFilter, "WMF Files (*.wmf)", "*.WMF")
strFilter = ahtAddFilterItem(strFilter, "All Files (*.*)", "*.*")
'You could add more file formats using the pattern above.

GetGraphic = ahtCommonFileOpenSave(InitialDir:="C:\", _
Filter:=strFilter, FilterIndex:=1, _
DialogTitle:="Select Graphic File to Import")

End Function

'------------------------------------------------------
Function StripChar(MyStr As String, RemoveChar As String) As Variant
On Error GoTo StripCharError

Dim strChar As String, strHoldString As String
Dim i As Integer

' Exit if the passed value is null.
If IsNull(MyStr) Then Exit Function

' Exit if the passed value is not a string.

If VarType(MyStr) <> 8 Then Exit Function

' Check each value for invalid characters.
For i = 1 To Len(MyStr)
strChar = Mid$(MyStr, i, 1)
If strChar = RemoveChar Then
' Do nothing
Else
strHoldString = strHoldString & strChar
End If
Next i

' Pass back corrected string.
StripChar = strHoldString

StripCharEnd:
Exit Function

StripCharError:
MsgBox Error$
Resume StripCharEnd
End Function

******************** Form (Class) Module Code *********************

Option Compare Database
Option Explicit

'------------------------------------------------------
Private Sub cmdImportFileNames_Click()
On Error GoTo Err_cmdImportFileNames_Click

Dim strFile As String
strFile = GetGraphic 'Call the function

Me![FilePath] = "#" & strFile & "#" ' The pound signs are required by the
hyperlink

Me![ctlImageFrame].Picture = StripChar(Me![FilePath], "#") 'But the pound
signs mess up the .Picture :(
Me.Refresh

Exit_cmdImportFileNames_Click:
Exit Sub

Err_cmdImportFileNames_Click:
MsgBox Err.Description
Resume Exit_cmdImportFileNames_Click

End Sub
'------------------------------------------------------

Private Sub Form_Current()
On Error Resume Next

If IsNull(Me![FilePath]) Then
Me![ctlImageFrame].Picture = "C:\Art\CAMERA.TIF" 'I use this to indicate
that no picture is available
Else
Me![ctlImageFrame].Picture = StripChar(Me![FilePath], "#") 'Remove the
pound signs, which mess up the .Picture
End If

End Sub
************************************************** **********
"Shumit Rehman" <sh**********@hotmail.com> wrote in message
news:3a**************************@posting.google.c om...
Hi

I have a table which has path names to photos I would like to view. I
would like to open some/any kind of image viewer(Paint) to see the
picture when I click the pathname.

The pictures are mostly scanned newspaper atricles which are too big
to just display on a form so I need the zoom and scroll features.

Im using access 2003

thanks in anticipation
Shumit

Nov 13 '05 #3

P: n/a
You can easily achieve Zoom/Scroll for your Images within the standard
Access GUI.
See:
http://www.lebans.com/loadjpeggif.htm

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"Shumit Rehman" <sh**********@hotmail.com> wrote in message
news:3a**************************@posting.google.c om...
Hi

I have a table which has path names to photos I would like to view. I
would like to open some/any kind of image viewer(Paint) to see the
picture when I click the pathname.

The pictures are mostly scanned newspaper atricles which are too big
to just display on a form so I need the zoom and scroll features.

Im using access 2003

thanks in anticipation
Shumit


Nov 13 '05 #4

P: n/a
Wow - three different ways. I'll try all three.

thanks.
Shumit
Nov 13 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.