【发布时间】:2011-09-12 22:36:25
【问题描述】:
我有一个将超链接插入新记录的按钮。该字段的 IsHyperlink 属性设置为“yes”,所以我得到了帮助,但是单击插入的路径不会去任何地方。我相信该按钮正在使用文件路径作为“要显示的文本”而不是“地址”来更新记录。
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"
【问题讨论】:
标签: vba hyperlink insert ms-access-2007