How can I Save Link/Path to Record After Browsing Folders?

  • Thread starter Kate Cz via AccessMonster.com
  • Start date
K

Kate Cz via AccessMonster.com

Hello - can anyone help with how to save the path to a diocument into a
textbox in a record on a form?

I have successfully used the code found at
http://www.mvps.org/access/api/api0001.htm to browse the folders, but am not
able to save the document path (as a hyperlink to be accessed at any time
once saved) into the textbox i have created for the link in each record.

One recommendation in this discussion group was to use the code Me.Text46 =
TestIt() to link (?) the code in my module (ie the code from
http://www.mvps.org/access/api/api0001) to the text box. This places the path
found during browsing into the text box, but once I exit, the link is not
saved. The user should be able to pull up the (word) document from the record.


Thank you very much!
 
B

BruceM

I'm not sure just what you need to do, but if you want to insert a link into
a text box, then go to the link by clicking in the text box, one option is
to have a command button with something like the following code:

Me.txtLink.SetFocus
DoCmd.RunCommand acCmdInsertHyperlink

This sets the focus to txtLink, which is a text box bound to a hyperlink
field in the Record Source table (the table behind your form). The next
line of code opens the standard Insert Hyperlink dialog box.

If the code you already have in place is generally working except for not
saving the link, the thing that occurs to me is that the text box would need
to be bound to a hyperlink field if it is not already.
 
L

Larry Linson

You can display values in Text Boxes, and those values can be saved into a
Field in a Table, but "saving in a Text Box" itself is very transitory...
only lasting while the TextBox is available. Once the Form is closed, unless
that Text Box was bound to a Field in a Table, the value is lost.

Perhaps I am misunderstanding your question.

The Imaging examples downloadable from http://accdevel.tripod.com include
samples where path and filename are saved, and where an image is saved as an
OLE Object. Neither of those is exactly what you are doing, but they may
give you a start on what you want to do. If you want to save the path and
filename as a hyperlink, you can review Help, search the Knowledge Base at
http://support.microsoft.com, and the online documentation at
http://msdn.microsoft.com.

Larry Linson
Microsoft Access MVP
 
K

Kate Cz via AccessMonster.com

Thanks Bruce and Larry. You are correct - the unbound nature of the text box
is the problem. So how about this: I have a text box that is bound to a table.
I would like the user to be able to browse for a document and insert it into
the correct field in the form (the bound text box). I see that this can be
done by right clicking in the empty field. The menu that appears has a
Hyperlink/Hyperlink Edit option from which I can browse for the document I
want and attach it as a hyperlink into the empty field. When I exit, it is
saved.

Is there a way to do this using a command button on the form? Or should i
just create a msg. box directing the user to excute the procedure described
above?

Thank you very much.
I'm not sure just what you need to do, but if you want to insert a link into
a text box, then go to the link by clicking in the text box, one option is
to have a command button with something like the following code:

Me.txtLink.SetFocus
DoCmd.RunCommand acCmdInsertHyperlink

This sets the focus to txtLink, which is a text box bound to a hyperlink
field in the Record Source table (the table behind your form). The next
line of code opens the standard Insert Hyperlink dialog box.

If the code you already have in place is generally working except for not
saving the link, the thing that occurs to me is that the text box would need
to be bound to a hyperlink field if it is not already.
Hello - can anyone help with how to save the path to a diocument into a
textbox in a record on a form?
[quoted text clipped - 15 lines]
Thank you very much!
 
B

BruceM

Create a hyperlink field in the table. I will call the field Link. Set its
data type to Hyperlink in table design view. Create a text box (txtLink) on
the form. Set its record source to Link (the hyperlink field in the table).
txtLink is now bound to Link. Create a command button on the form. Place
the following code in its Click event:

Me.txtLink.SetFocus
DoCmd.RunCommand acCmdInsertHyperlink

This sets the focus to txtLink, then opens the standard Insert Hyperlink
dialog box.

Most of this is from my first posting. If you have questions about how to
do any of this, or if the explanation is unclear, by all means ask for
clarification or further explanation, but I have to wonder why after I
explained how to use a command button you replied by asking if there was a
way to do this with a command button.

Kate Cz via AccessMonster.com said:
Thanks Bruce and Larry. You are correct - the unbound nature of the text
box
is the problem. So how about this: I have a text box that is bound to a
table.
I would like the user to be able to browse for a document and insert it
into
the correct field in the form (the bound text box). I see that this can be
done by right clicking in the empty field. The menu that appears has a
Hyperlink/Hyperlink Edit option from which I can browse for the document I
want and attach it as a hyperlink into the empty field. When I exit, it is
saved.

Is there a way to do this using a command button on the form? Or should i
just create a msg. box directing the user to excute the procedure
described
above?

Thank you very much.
I'm not sure just what you need to do, but if you want to insert a link
into
a text box, then go to the link by clicking in the text box, one option is
to have a command button with something like the following code:

Me.txtLink.SetFocus
DoCmd.RunCommand acCmdInsertHyperlink

This sets the focus to txtLink, which is a text box bound to a hyperlink
field in the Record Source table (the table behind your form). The next
line of code opens the standard Insert Hyperlink dialog box.

If the code you already have in place is generally working except for not
saving the link, the thing that occurs to me is that the text box would
need
to be bound to a hyperlink field if it is not already.
Hello - can anyone help with how to save the path to a diocument into a
textbox in a record on a form?
[quoted text clipped - 15 lines]
Thank you very much!
 
K

Kate Cz via AccessMonster.com

BruceM said:
Create a hyperlink field in the table. I will call the field Link. Set its
data type to Hyperlink in table design view. Create a text box (txtLink) on


Thanks Bruce, this worked fine and thank you for the extra explanation which
helped me figure it out.
The reason I asked about the command button again was because I was looking
to make it as easy for the user to browse folders as possible. A window comes
up allowing the users to browse folders immediately using this code:
Me.Text50 = TestIt()
but it wasn't saving the link. The code you provided does cause the link to
be saved though the user enters the folders available for browsing through a
window titled "edit hyperlink" from which they choose to browse files (unlike
the other code which took them right to the folders). If you have any ideas
about how to go directly to the browse folders window, let me know, otherwise
the code you provided works just fine, just with an extra step. Hopefully
this makes sense. Much appreciated~
 
B

BruceM

I have several times wished that I could go directly to the folders window,
but have not discovered a way to do so. That's not to say there is no way,
but only that I do not know what it is.
 

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