Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Inserting "folder" location in Hyperlink field

Posted on 2014-02-21
5
Medium Priority
?
455 Views
Last Modified: 2014-02-22
Hi,

I have a hyperlink field in my form.

I want my users to
identify an excel spreadsheet in a specific folder and then

"paste" a link to that spreadsheet into my access form.


I want this to be a simply cut and paste.

Question: How can I CUT a hyperlink that hold my folder path AND my file name.


The end result should be something like;
C:\mydocuments\myExcel\Personal\Bankrec.xls

Note that I am already able to "cut" the folder path ...... but I am finding that I need to KEY in the actual file name.  I.e. I need to key in the "bankrec.xls" .... How do I avoid keying in the filename
0
Comment
Question by:Patrick O'Dea
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 16

Accepted Solution

by:
Sheils earned 2000 total points
ID: 39878895
You can do that with vba. The code is as follows:-

Function SelectFile() As String
      
        On Error GoTo ExitSelectFile
          
        Dim objFileDialog    As Object
        Set objFileDialog = Application.FileDialog(1)
          
        With objFileDialog
          
            .AllowMultiSelect = False
            .Show
               
            Dim varSelectedItem As Variant
      
            For Each varSelectedItem In .SelectedItems
      
                SelectFile = varSelectedItem
               
            Next varSelectedItem
                  
       End With
         
    ExitSelectFile:
      
    Set objFileDialog = Nothing
      
End Function

Open in new window


This will open the dialog box and you can select a file from any folder.

I have attached an example. Open the form and click the button to see how it works
dbselectfile.accdb
0
 

Author Closing Comment

by:Patrick O'Dea
ID: 39879158
Purrfect!
0
 

Author Comment

by:Patrick O'Dea
ID: 39879174
Actually,

Can I re-open this question??

This link insert fine into the table BUT .... it does not open when I click it in the form..??

Perhaps, the link should be enclosed in quote?? How do I do this?

Thanks
0
 
LVL 16

Expert Comment

by:Sheils
ID: 39879801
Create a new module and paste in the following code:

Private Declare Function ShellExecuteA Lib "shell32.dll" _
(ByVal hWnd As Long, _
ByVal strOperation As String, _
ByVal strFile As String, _
ByVal strParameters As String, _
ByVal strDirectory As String, _
ByVal nShowCmd As Long) As Long
 
Private Declare Function GetDesktopWindow Lib "user32" () As Long
____________________________________________________________
 
Function OpenFile(strFilePath)
  
    lngreturn = ShellExecuteA(GetDesktopWindow(), "OPEN", strFilePath, "", "", vbNormalFocus)
  
    If Not ((lngreturn < 0) Or (lngreturn > 32)) Then
       
        MsgBox "Sorry, There was a problem opening the selected file", vbExclamation
  
    End If
  
End Function

Open in new window


Then in the form textbox on double click even add the following:

OpenFile(Me.textboxname)
0
 

Author Comment

by:Patrick O'Dea
ID: 39879842
Thanks very much!

I got it now.  Very clever!
0

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question