C
charleeorchuck
I'm using MS Access 2000 and would like to have an image associated with the
record. I have it set up so that the user clicks a button to add the image,
then the filepath is stored. But I would like the image to be seen while the
user is looking at the form. For some reason I can't get it to work. I got
the code from examples and tutorials, as I'm very new to this and don't know
VBA at all. Here is the code I have:
Private Sub cmdAddImage_Click()
Dim strFilter As String
Dim lngflags As Long
Dim varFileName As Variant
strFilter = "All Files (*.*)" & vbNullChar & "*.*" _
& vbNullChar & "All Files (*.*)" & vbNullChar & "*.*"
lngflags = tscFNPathMustExist Or tscFNFileMustExist _
Or tscFNHideReadOnly
varFileName = tsGetFileFromUser( _
fOpenFile:=True, _
strFilter:=strFilter, _
rlngflags:=lngflags, _
strDialogTitle:="Please choose a file...")
If IsNull(varFileName) Then
Else
Me![memSiteImage] = varFileName
Forms![sfrmDescription].Form.Requery
End If
cmdAddImage_End:
On Error GoTo 0
Exit Sub
End Sub
Function setImagePath()
Dim strImagePath As String
On Error GoTo PictureNotAvailable
strImagePath = Me.memSiteImage
Me.memSiteImage.Locked = True
Me.memSiteImage.Enabled = False
Me.ImageFrame.Picture = strImagePath
Exit Function
PictureNotAvailable:
strImagePath = "C:NoImage.gif"
Me.ImageFrame.Picture = strImagePath
End Function
Private Sub memSiteImage_AfterUpdate()
setImagePath
Forms![Description].Form.Requery
End Sub
Any help would be gladly appreciated!!!
record. I have it set up so that the user clicks a button to add the image,
then the filepath is stored. But I would like the image to be seen while the
user is looking at the form. For some reason I can't get it to work. I got
the code from examples and tutorials, as I'm very new to this and don't know
VBA at all. Here is the code I have:
Private Sub cmdAddImage_Click()
Dim strFilter As String
Dim lngflags As Long
Dim varFileName As Variant
strFilter = "All Files (*.*)" & vbNullChar & "*.*" _
& vbNullChar & "All Files (*.*)" & vbNullChar & "*.*"
lngflags = tscFNPathMustExist Or tscFNFileMustExist _
Or tscFNHideReadOnly
varFileName = tsGetFileFromUser( _
fOpenFile:=True, _
strFilter:=strFilter, _
rlngflags:=lngflags, _
strDialogTitle:="Please choose a file...")
If IsNull(varFileName) Then
Else
Me![memSiteImage] = varFileName
Forms![sfrmDescription].Form.Requery
End If
cmdAddImage_End:
On Error GoTo 0
Exit Sub
End Sub
Function setImagePath()
Dim strImagePath As String
On Error GoTo PictureNotAvailable
strImagePath = Me.memSiteImage
Me.memSiteImage.Locked = True
Me.memSiteImage.Enabled = False
Me.ImageFrame.Picture = strImagePath
Exit Function
PictureNotAvailable:
strImagePath = "C:NoImage.gif"
Me.ImageFrame.Picture = strImagePath
End Function
Private Sub memSiteImage_AfterUpdate()
setImagePath
Forms![Description].Form.Requery
End Sub
Any help would be gladly appreciated!!!