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