1
在表格中,我有多个附件字段,我插入超链接(右键单击编辑超链接)。 所有文件都位于一个networkdirectory在Access中浏览文件按钮保存为超链接
\\ap1\tools\db...
我想有一个按钮,与上打开“浏览文件”点击事件
\\ap1\tools\db...
开始,并且放选定的文件作为超链接进入相应的字段。
我认为vba是最好的解决方案,但我不知道从哪里开始。
在表格中,我有多个附件字段,我插入超链接(右键单击编辑超链接)。 所有文件都位于一个networkdirectory在Access中浏览文件按钮保存为超链接
\\ap1\tools\db...
我想有一个按钮,与上打开“浏览文件”点击事件
\\ap1\tools\db...
开始,并且放选定的文件作为超链接进入相应的字段。
我认为vba是最好的解决方案,但我不知道从哪里开始。
经过一番研究,我相信我已经解决了我的问题
Private Sub btnAttachment1_Click()
Const msoFileDialogFilePicker As Long = 3
Dim fd As Object
'Create a FileDialog object as a File Picker dialog box.
Set fd = Application.FileDialog(msoFileDialogFilePicker)
'Use a With...End With block to reference the FileDialog object.
With fd
'Set the initial path to the D:\Documents\ folder.
.InitialFileName = "\\ap1\tools\db\"
.Title = "Select Attachment"
'Use the Show method to display the File Picker dialog box and return the user's action.
'If the user presses the action button...
If .Show = -1 Then
' DoCmd.GoToRecord , "", acNewRec
Me![Attachment1] = "#" & .SelectedItems(1) & "#"
' **
'If the user presses Cancel...
Else
End If
End With
'Set the object variable to Nothing.
Set fd = Nothing
End Sub