Solved

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

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
No matter the version of Windows you are using, you may have some problems with Windows Search running too slow or possibly not running at all. Before jumping into how you can solve this issue, just know there are many other viable alternative deskt…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

746 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

9 Experts available now in Live!

Get 1:1 Help Now