By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,335 Members | 2,258 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,335 IT Pros & Developers. It's quick & easy.

Finding Images in FileName\Image

P: n/a
I'm trying to move my images from my main folder to an image folder for the
database to store pictures of animals. I borrowed code that works great if I
put all the images in the main folder where the db is located. I would like to
move them to their own folder and I don't know where to begin.

here is the code:

Private Sub Form_Activate()
'find the path of the current database
'which is where the jpegs are stored
Set db = CurrentDb
filename = db.Name
pathname = Mid(filename, 1, Len(filename) - Len(Dir(filename)))
End Sub

_______________________

Private Sub Form_Current()
On Error GoTo Err_cmdClose_Click

'set the picture path
Me.ImageAn.Picture = pathname & Me.Breed & ".jpg"

Exit_cmdClose_Click:
Exit Sub

Err_cmdClose_Click:
If err.Number = 2220 Then 'can't find the file
Resume Next
Else
MsgBox err.Description
Resume Exit_cmdClose_Click
End If
End Sub

Any help would be greatly appreciated.

Michael
Nov 12 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Lumpierbritches wrote:
I'm trying to move my images from my main folder to an image folder for the
database to store pictures of animals. I borrowed code that works great if I
put all the images in the main folder where the db is located. I would like to
move them to their own folder and I don't know where to begin.

here is the code:

Private Sub Form_Activate()
'find the path of the current database
'which is where the jpegs are stored
Set db = CurrentDb
filename = db.Name
pathname = Mid(filename, 1, Len(filename) - Len(Dir(filename)))
End Sub

_______________________

Private Sub Form_Current()
On Error GoTo Err_cmdClose_Click

'set the picture path
Me.ImageAn.Picture = pathname & Me.Breed & ".jpg"

Exit_cmdClose_Click:
Exit Sub

Err_cmdClose_Click:
If err.Number = 2220 Then 'can't find the file
Resume Next
Else
MsgBox err.Description
Resume Exit_cmdClose_Click
End If
End Sub

Any help would be greatly appreciated.

Michael


Me.ImageAn.Picture = pathname & "images\" & Me.Breed & ".jpg"

--
Error reading sig - A)bort R)etry I)nfluence with large hammer
Nov 12 '05 #2

P: n/a
Trevor Best wrote:
Err_cmdClose_Click:
If err.Number = 2220 Then 'can't find the file
Resume Next
Else
MsgBox err.Description
Resume Exit_cmdClose_Click
End If


A nice touch would be to create a bitmap with a red X on it, a la IE
broken pic, then set the picture to that if it doesn't exist.

--
Error reading sig - A)bort R)etry I)nfluence with large hammer
Nov 12 '05 #3

P: n/a
Thank you for all the suggestions and the fix, I greatly appreciate it.

Michael
Nov 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.