Finding file and storing its location in field

  • Thread starter Thread starter Neil Greenough
  • Start date Start date
N

Neil Greenough

I have a field in a table set as an OLE Object. I don't know however if this
is correct.

I want to be able to double click in the field, and a window appear, in
which I can locate a certain file saved on my computer. Then, once I select
a file, I want its location to be saved in that field in the table so that,
when I return to that individual entry and double click in the field, the
document actually opens.

Any ideas? This is quite urgent!

Thanks in advance :)
 
Setup the field in your table as hyperlink, to point to a file or even a web
page:

-Right click on the field, select Hyperlink\Edit Hyperlink
-Browse for your file or type the web address directly
-Next time you open the table you simply click on the field and the
reference will open
 
Hi Neil,

In general it's not a good idea to store documents in OLE fields.
Instead, leave them as files on disk and just store their locations.

Far the simplest way to do something very close to what you ask is to
use a hyperlink field. Then you just need to drag a file from a My
Computer window (or similar) onto the field to store its location as a
hyperlink, and a click on the field will open the document.

To do exactly waht you ask, use a text field, and a textbox bound to the
field on a form bound to (a query on) the table. The logic in the
textbox's DoubleClick event procedure would be like this:

If IsNull(Me.ActiveControl.Value) Then 'field is empty
'Invoke File|Open dialog, get filespec, and place in field
Else 'field contains something, hopefully a filespec
Application.FollowHyperlink Me.ActiveControl.Value
End If

There's code at http://www.mvps.org/access/api/api0001.htm that lets you
invoke the standard File|Open dialog.
 
Thanks John! Much appreciated!

Neil

John Nurick said:
Hi Neil,

In general it's not a good idea to store documents in OLE fields.
Instead, leave them as files on disk and just store their locations.

Far the simplest way to do something very close to what you ask is to
use a hyperlink field. Then you just need to drag a file from a My
Computer window (or similar) onto the field to store its location as a
hyperlink, and a click on the field will open the document.

To do exactly waht you ask, use a text field, and a textbox bound to the
field on a form bound to (a query on) the table. The logic in the
textbox's DoubleClick event procedure would be like this:

If IsNull(Me.ActiveControl.Value) Then 'field is empty
'Invoke File|Open dialog, get filespec, and place in field
Else 'field contains something, hopefully a filespec
Application.FollowHyperlink Me.ActiveControl.Value
End If

There's code at http://www.mvps.org/access/api/api0001.htm that lets you
invoke the standard File|Open dialog.
 
Back
Top