Solved

Access 2007 capturing hyperlink in form using VB Script - open to correct folder

Posted on 2013-05-26
3
579 Views
Last Modified: 2013-05-27
I am running the following VB Script to capture a hyperlink to a file.  I need the code that will tell the button to open to a specific folder.  The folder I want to use is

\\crserver2\inboxes\

The current code is this:

Private Sub Command5_Click()

On Error GoTo Err_Command5_Click

Me.[Attachment].SetFocus
DoCmd.RunCommand acCmdInsertHyperlink

Exit_Command5_Click:
    Exit Sub

Err_Command5_Click:
    If Err.Number = 2501 Then
        Resume Next
    Else

        MsgBox Err.Description
        Resume Exit_Command5_Click
    End If
End Sub
0
Comment
Question by:SoundBytes
  • 2
3 Comments
 
LVL 20

Expert Comment

by:GrahamMandeno
ID: 39198228
I'm not clear about what you are actually asking.  Do you want to open an Explorer window on the given folder?  If so, use FollowHyperlink:
Application.FollowHyperlink "\\crserver2\inboxes\"

-- Graham Mandeno [Access MVP 1996-2013]
0
 
LVL 20

Accepted Solution

by:
GrahamMandeno earned 465 total points
ID: 39198288
Or, if you want to select a file from that folder, use some code like this:
Dim fd As Object
Dim strFilename As String
  Set fd = Application.FileDialog(3) ' msoFileDialogFilePicker
  With fd
    .Title = "Select a file"
    .AllowMultiSelect = False
    .InitialFileName = "\\crserver2\inboxes\"
    If .Show = 0 Then
      MsgBox "You clicked Cancel"
      Exit Sub
    Else
      strFilename = .SelectedItems(1)
    End If
  End With
  Set fd = Nothing
' go ahead and do something with strFilename

Open in new window

-- Graham
0
 

Author Closing Comment

by:SoundBytes
ID: 39199526
Like a charm dude!  Thanks!!!
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Microsoft Office Picture Manager is not included in Office 2013. This comes as a shock to users upgrading from earlier versions of Office, such as 2007 and 2010, where Picture Manager was included as a standard application. This article explains how…
Outlook Free & Paid Tools
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.

920 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now