Hi
I have a form which shows individual records for users and I want to link photos for each record from a network folder rather than embedding them in the database as good practice suggests.
I've been using the database expample from http://www.databasedev.co.uk/image-form.html as a guide and have got it doing all I want other than actually displaying the picture in the picture control.
Form name: tblPerson
Picture path text field: txtImageName
Image Control: ImageFrame
Command button: cmdAddImage
Command button: cmdDeleteImage
The Event Procedure is assigned to the On Click event and looks like:
The image path is added to the picture path text field as expected but it's just the picture that isn't being displayed regardless of the requery at the end.
I'm a bit stuck here so would appreciate any help
I have a form which shows individual records for users and I want to link photos for each record from a network folder rather than embedding them in the database as good practice suggests.
I've been using the database expample from http://www.databasedev.co.uk/image-form.html as a guide and have got it doing all I want other than actually displaying the picture in the picture control.
Form name: tblPerson
Picture path text field: txtImageName
Image Control: ImageFrame
Command button: cmdAddImage
Command button: cmdDeleteImage
The Event Procedure is assigned to the On Click event and looks like:
Code:
Private Sub cmdAddImage_Click()
On Error GoTo cmdAddImage_Err
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![txtImageName] = varFileName
Forms![tblPerson].Form.Requery
End If
cmdAddImage_End:
On Error GoTo 0
Exit Sub
cmdAddImage_Err:
Beep
MsgBox Err.Description, , "Error: " & Err.Number _
& " in file"
Resume cmdAddImage_End
End Sub
Function setImagePath()
Dim strImagePath As String
On Error GoTo PictureNotAvailable
strImagePath = Me.txtImageName
Me.txtImageName.Locked = True
Me.txtImageName.Enabled = False
Me.ImageFrame.Picture = strImagePath
Exit Function
PictureNotAvailable:
strImagePath = "C:\Windows\Wind.bmp"
Me.ImageFrame.Picture = strImagePath
End Function
Private Sub cmdDeleteImage_Click()
Me.txtImageName.Enabled = True
Me.txtImageName.SetFocus
Me.txtImageName.Locked = False
Me.txtImageName.Text = ""
Me.txtImageName.SetFocus
Forms![tblPerson].Form.Requery
Me.txtImageName.Locked = True
Me.txtImageName.Enabled = False
End Sub
Private Sub txtImageName_AfterUpdate()
setImagePath
Forms![tblPerson].Form.Requery
End Sub
The image path is added to the picture path text field as expected but it's just the picture that isn't being displayed regardless of the requery at the end.
I'm a bit stuck here so would appreciate any help
Last edited: