MS Access - 在表中保存相对路径并在单击链接时打开文件 [英] MS Access - Save relative path in table and open file on clicking the link

查看:283
本文介绍了MS Access - 在表中保存相对路径并在单击链接时打开文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我有一个有两个字段调用的表单;来源"和"目的地"采取形式tblSou。源字段保存文档源,目标字段保存
目标路径(这是映射到所有用户中本地PC的服务器路径)。现在有两件事我想实现:


< br style ="font-size:16px; font-family:'Open Sans',sans-serif;颜色:#222222">
1。保存相对路径。 (如何保存相对路径?例如路径是(W:\\Document\test.pdf)如何保存它的相对路径?)



2。在桌面上单击该相对链接时,它应该打开该文件。 (当在表格中点击链接时,即目标字段,它不打开该文档,该怎么做?)

是否可以通过VBA获取文件夹的根目录并附加文件名?

如果需要,源和目的地字段也有代码 

Also Source and Destination field have code if require 

Private Sub txtSource_Click()
 Dim Dialog      As FileDialog
    
    Dim Selected    As Long
    
    Set Dialog = FileDialog(msoFileDialogFilePicker)
    With Dialog
        .AllowMultiSelect = False
        .InitialFileName = Nz(Me!txtSource.Value)
        .Title = "Select file to copy"
        Selected = .Show
        If Selected <> 0 Then
            Me!txtSource.Value = .SelectedItems.Item(1)
        End If
    End With
    
    Cancel = True
End Sub

Private Sub txtTarget_Click()
Dim Dialog      As FileDialog
    
    Dim Selected    As Long
    
    Set Dialog = FileDialog(msoFileDialogSaveAs)
    With Dialog
        .AllowMultiSelect = False
        .InitialFileName = Nz(Me!txtTarget.Value)
        .Title = "Name saved file"
        Selected = .Show
        If Selected <> 0 Then
            Me!txtTarget.Value = .SelectedItems.Item(1)
            If Not IsNull(Me!txtSource.Value) Then
                 FileCopy Me!txtSource.Value, Me!txtTarget.Value
            End If
        End If
    End With
    
    Cancel = True
End Sub

< span style ="color:#222222; font-family:'Open Sans',sans-serif; font-size:16px">任何帮助都将不胜感激。



谢谢。

Any help would be appreciated.

Thank you.

推荐答案

嗨Wsm93,

Hi Wsm93,

你可以使用
申请表。 FollowHyperli nk
 打开文件的方法,就像。

You could use Application.FollowHyperlink method to open the file , just like.

Application.FollowHyperlink Me!txtTarget.Value

最诚挚的问候,

Terry


这篇关于MS Access - 在表中保存相对路径并在单击链接时打开文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆