Ms access 在Access中浏览文件按钮另存为超链接

Ms access 在Access中浏览文件按钮另存为超链接,ms-access,vba,Ms Access,Vba,在表单中,我有多个附件字段,在其中插入超链接(右键单击“编辑超链接”)。 所有文件都位于网络目录中 \\ap1\tools\db... 我想有一个按钮,点击事件,打开一个“浏览文件”开始在 \\ap1\tools\db… 这会将所选文件作为超链接放入相应的字段中 我认为vba是最好的解决方案,但我不知道从哪里开始。经过一些研究,我相信我已经解决了我自己的问题 Private Sub btnAttachment1_Click() Const msoFileDialogFilePicke

在表单中,我有多个附件字段,在其中插入超链接(右键单击“编辑超链接”)。 所有文件都位于网络目录中

\\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