+ Post New Thread
Results 1 to 2 of 2
Office Software Thread, Linking a picture to a form record from network folder in Technical; Hi I have a form which shows individual records for users and I want to link photos for each record ...
  1. #1
    randle's Avatar
    Join Date
    Dec 2006
    Location
    Chelmsford, Essex
    Posts
    561
    Thank Post
    59
    Thanked 16 Times in 15 Posts
    Rep Power
    18

    Linking a picture to a form record from network folder

    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:

    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

  2. #2
    randle's Avatar
    Join Date
    Dec 2006
    Location
    Chelmsford, Essex
    Posts
    561
    Thank Post
    59
    Thanked 16 Times in 15 Posts
    Rep Power
    18
    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

SHARE:
+ Post New Thread

Similar Threads

  1. Replies: 4
    Last Post: 14th October 2011, 02:40 PM
  2. Replies: 5
    Last Post: 9th March 2008, 12:15 AM
  3. Replies: 1
    Last Post: 21st December 2007, 06:27 PM
  4. Replies: 7
    Last Post: 11th October 2007, 10:18 AM
  5. Replies: 6
    Last Post: 22nd March 2006, 07:26 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •