deleting a external file from access 2007

O

OD

I have a form that has a hyperlink field. When the user deletes a record I
need to delete the file that the hyperlink points to.

When I store the hyperlink field info into a var I cannot get Kill to delete
the file. If I type the full path manually kill works fine. I don’t know
where the file will be stored so I need to get the full path. I tried to use
fullpath, access did not like it.
EXAMPLE:
varMyString = [Document Location] Note: Hyperlink field
I don’t know what I’m doing wrong.
Thanks
OD
 
D

Dale Fye

OD,

The problem with hyperlink fields is that they contain more than just the
path and file name. Which is why I never use hyperlink fields. Instead I
use a text field and use the double click event of the textbox associated
with the field (or a command button) to actually jump to or open the
hyperlink.

If you convert the text of the hyperlink field using cStr([fieldname]), it
adds a # to the front and back of the path/filename, so if you do something
like:

Kill Replace(cstr([Document Location]))

it should work.

Dale
 
O

OD

Thanks i found if you use
varFile = Application.HyperlinkPart([Document Location], acDisplayedValue)
it returns the string with out the extra chars.

I still have a problem if the file is in a sub directory of the current dir
it only returns relative path not the full path, if not then it returns the
full path.

Thanks Dale
Always more than one way to kill a kitty

Dale Fye said:
OD,

The problem with hyperlink fields is that they contain more than just the
path and file name. Which is why I never use hyperlink fields. Instead I
use a text field and use the double click event of the textbox associated
with the field (or a command button) to actually jump to or open the
hyperlink.

If you convert the text of the hyperlink field using cStr([fieldname]), it
adds a # to the front and back of the path/filename, so if you do something
like:

Kill Replace(cstr([Document Location]))

it should work.

Dale

OD said:
I have a form that has a hyperlink field. When the user deletes a record I
need to delete the file that the hyperlink points to.

When I store the hyperlink field info into a var I cannot get Kill to
delete
the file. If I type the full path manually kill works fine. I don't know
where the file will be stored so I need to get the full path. I tried to
use
fullpath, access did not like it.
EXAMPLE:
varMyString = [Document Location] Note: Hyperlink field
I don't know what I'm doing wrong.
Thanks
OD


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top