1
我有一個按鈕,它將超鏈接插入到新記錄中。該字段的IsHyperlink屬性設置爲「是」,所以我得到了該手,但單擊插入的路徑不會去任何地方。我相信按鈕正在更新記錄,文件的路徑是「要顯示的文本」而不是「地址」。VBA MS Access 2007超鏈接插入按鈕
Private Sub MSDS_btn_Click()
Dim fd As Office.FileDialog
'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 = "D:\Documents\"
.Title = "Select MSDS"
'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![Link MSDS] = .SelectedItems(1)
**
'If the user presses Cancel...
Else
End If
End With
'Set the object variable to Nothing.
Set fd = Nothing
End Sub
我知道把下面的代碼放在**在Excel中工作,我喜歡它後會在Access中工作!
ActiveSheet.Hyperlinks.Add Anchor:=Cells(ActiveCell.row, Range("LinkCol").Column), Address:=.SelectedItems(1), TextToDisplay:="MSDS"
它的工作原理!謝謝@HansUp – Denbigh