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