Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code Dysfunction (Display Images from Folder)

Status
Not open for further replies.

LadyDev

Programmer
Jan 29, 2003
86
0
0
US
I got this code from Candace Tripp's website. It's used display images from a folder in a from - storing the image in a relative path in the table. The code worked with her desgin, but she used a single form. I have a form and subform combo. Choice from combo box (cmboChoice)displays the image on the main form (DocView)and other text info is also displayed in the subform (AvailableData). I keep getting this error "Can not open file F:\images\mdb\". It's identifying the correct folder, but can't open it - Why?

Private Sub Form_Current()
On Error GoTo err_Form_Current
If Not Forms!frmDocView!PicImage.Picture = "" Or Not IsNull(Forms!frmDocView!IMAGE_NAME) Then
Forms!frmDocView!PicImage.Picture = GetPathPart & Forms!frmDocView!IMAGE_NAME
Else
Forms!frmDocView!PicImage.Picture = ""
End If
exit_Form_Current:
Exit Sub

err_Form_Current:
MsgBox Err.Description
Resume exit_Form_Current

End Sub

Private Sub Form_Open(Cancel As Integer)
On Error GoTo Err_Form_Open

If IsNull(Forms!frmDocView!IMAGE_NAME) Or
Forms!frmDocView!IMAGE_NAME = "" Then
' do nothing
Else
Forms!frmDocView!PicImage.Picture = GetPathPart & Forms!frmDocView!IMAGE_NAME
End If

Exit_Form_Open:
Exit Sub

Err_Form_Open:
MsgBox Err.Description
Resume Exit_Form_Open

End Sub

Private Function GetPathPart() As String
' Comments : Returns the path part of a string
' Parameters: strPath - string to parse
' Returns : path part
'
Dim db As DAO.Database
Dim strPath As String
Dim intCounter As Integer

Set db = CurrentDb
strPath = db.Name
db.Close
Set db = Nothing

For intCounter = Len(strPath) To 1 Step -1
If Mid$(strPath, intCounter, 1) = "\" Then
Exit For
End If
Next intCounter

GetPathPart = Left$(strPath, intCounter)

End Function

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top