Solved

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

Posted on 2013-05-26
3
580 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

Outlook Free & Paid Tools
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
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.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…

770 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