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