Open and Automatically save an image

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I need to be able to open a bmp image and automatically save it into a
folder and also update the image field in the record so that that particular
image is referenced for that record.

I have the images appearing correctly if I manually enter the path in the
image field in the record and they show the appropriate image for the
employee.

I also have code that opens the save as dialogue but when I click on save it
does not seem to save the file anywhere. I am using the code from
http://www.mvps.org/access/api/api0001.htm

What I would like to do is be able to browse to a file and then save that
chosen bmp file into another directory and also update the record with the
path given when it was saved.

Any assistance is appreciated as I have hit a wall
 
This really takes a bit of advanced VBA coding. You will want to use a
common dialog box (ActiveX Control) to browse the file you want copy to your
folder. The common dialog box will return the path, file name, and extention
as one string. Once you have that, you can use the common dialog box again
to be able to save it where you want it. Then take the return value from the
save version from the common dialog box and store it in the field in our
table that gives you the link. (The field should be a Hyperlink data type).
You will need to register the common dialog box (if you have not already),
and put it on your form as a control. I usually make it invisible and call
it from a command button. In the first example below, strOldPath will
contain the path, file name and extension of the file you want to copy. Call
it again as in the second example with strNewPath and and you will have the
destination so you can save it in your table as a link. To make it pretty,
you will have to set some of the properties for the default folders,
extension, etc. that you want. You will need a good Access Reference Manual
for that. I use "Access 2002 Desktop Developer's Handbook" by Paul Litwn,
Ken Getz, and Mike Gunderloy. It has everthing you ever wanted to know.

cdlBackEnd.ShowOpen
If Err = 32755 Then 'Cancel was selected
DoCmd.Quit
Else
strOldPath = cdlBackEnd.FileName
End If

cdlBackEnd.ShowSave
If Err = 32755 Then 'Cancel was selected
DoCmd.Quit
Else
strOldPath = cdlBackEnd.FileName
End If

Hope this helps, good luck!
 
Dave,
I forgot something important. The common dialog box will not actually save
the file for you. It will only give you the paths you want. You will then
need to use the Filecopy statement to actually copy the file into place.
Note, you will get an error if the file you are trying to copy is open.
Pardon the omission.
 
Thanks Klatuu,

I was on the right track but you have clarified it for me. I kept assuming
it should be saving the file for me but now I realise it doesn't and I can
use file copy to achieve the result.
 
Back
Top