Jump to content
EduGeek EdSec 2026 is Go! 27th Oct in Derby! Join us for a day of EdTech security focused talks, networking, and an evening social ×

Recommended Posts

Posted

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:

 

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

Posted
Not to worry, I've sorted this now. I just had to change the Control source property of the Image frame to the txtImageName field and now shows as expected. Simples http://images.access-programmers.co.uk/forums/images/smilies/wink.gif

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...