473,397 Members | 2,033 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Access VBA to browse for pdf, attach path to field, and create functioning hyperlink.

I have a 2003 Access db with a form for entering customer info. For data entry purposes, I want to be able to enter a new customer into the form, and click a browse button to browse to a pdf that is a scan of the customer's driver's license. When other employees are working with the records, I want them to be able to click on the path to the pdf, and have it actually open the pdf in their default pdf viewer. I found code in a 2007 post that uses the following for generating the browse button and populating the text box with the document path, but it does not create a functioning hyperlink. How can I modify the below to save the path as a working hyperlink?

Thanks in advance!

Expand|Select|Wrap|Line Numbers
  1. Private Sub btnPickFile_Click() 
  2.  
  3.     Dim dlgPickFiles As Office.FileDialog 
  4.     Dim strList As String 
  5.  
  6.     Set dlgPickFiles = Application.FileDialog(msoFileDialogFilePicker) 
  7.  
  8.     With dlgPickFiles 
  9.         .AllowMultiSelect = False 
  10.         With .Filters 
  11.             .Clear 
  12.             .Add "Excel files (*.xls)", "*.xls" 
  13.         End With 
  14.         .Show 
  15.         Me.txtFileName = .SelectedItems(1) 
  16.     End With 
  17.  
  18.     Set dlgPickFiles = Nothing 
  19.  
  20. End Sub 
  21.  
May 9 '11 #1
4 4137
TheSmileyCoder
2,322 Expert Mod 2GB
First ensure that me.txtFileName is bound to a hyperlink type field.

Then you need to wrap the link like so:
me.txtFileName="Example#C:\Example.txt#"
Example would be the text displayed in the field, whereas C:\Example.txt is the actual link address.
In your case, you need to decide what you want the display value to be, a simple example, just showing License in the field:
Expand|Select|Wrap|Line Numbers
  1. Me.txtFileName = "License#" & .SelectedItems(1) & "#"
May 10 '11 #2
NeoPa
32,556 Expert Mod 16PB
Error 7980: HyperlinkAddress or HyperlinkSubAddress read-only for Hyperlink may help when it comes to determining exactly how to work with your hyperlink. Smiley's response isn't wrong at all, this just covers it in more detail.
May 10 '11 #3
Thanks so much to both of you for your help! This gets me over a major hurdle.
May 10 '11 #4
NeoPa
32,556 Expert Mod 16PB
Very pleased to hear it Craig, and you're welcome of course :-)
May 10 '11 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: RickL | last post by:
How do you attach a file to a hyperlink so that it cab be opened when clicked? I am new to .net and web development and I need to attach a file to an asp page so that when click it can be opened it...
1
by: Mundungus Fletcher | last post by:
Greetings, I apologize if this has been asked and answered a lot. Googling showed me a few people asking, but I didn't find any clear-cut answers. I have a vendor db, and I need to create a...
4
by: Dennis C. Drumm | last post by:
Is there a way with C# to allow one class access to a method or field of another class, without making that method or field visible to all other classes, as would be the case when making the method...
1
by: Jody Gelowitz | last post by:
We are having an issue in that when trying to read a file that is on Server2 from Server1 (through our ASP.NET project), we receive the error: Access to the path "\\Server2\MyShare\MyFile.tif" is...
3
by: David Thielen | last post by:
Hi; I created a virtual directory in IIS 6.0 and my asp.net app runs fine. But when it tries to write a file I get: Access to the path is denied. - C:\Inetpub\wwwroot\RunReportASP\images ...
5
by: smitacharya | last post by:
Hi, I am trying to convert the text on status bar into hyperlink. Is there a way to do so? Thank you in advance. -Smita
3
by: sloesch | last post by:
I am working with VS.net 2003, framework 1.1, developing with VB.net, and ASP.net, and I would like to know how you can create a dynamic hyperlink on the fly to a document stored in a SQL database?...
1
by: Santosh | last post by:
Hii i am writting following code for attaching file to the emails it runs well on the local server but when i run it on domain servert then it gives an error Access to the path is denied. can any...
5
by: Thirdworld | last post by:
I'm trying to create a hyperlink button on a form that does the following: 1. User clicks on button 2. The default 'insert hyperlink' window appears 3. User selects the desired file 4. User...
8
by: remya1000 | last post by:
i'm using VB \ ASP.NET. i'm trying to display some values in Gridview. but i don't know how many columns i need to display. at run time only i will come to know how many columns i need to...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.