适用于:Access 2013、Office 2013
返回一个值,指示 Recordset 对象是否支持可使用 Bookmark 属性来设置的书签。
语法
表达式 。可书签
表达 一个代表 Recordset2 对象的变量。
备注
在设置或检查 Bookmark 属性之前,检查 Recordset 对象的 Bookmarkable 属性设置。
对于完全基于 Microsoft Access 数据库引擎表的 Recordset 对象, Bookmarkable 属性的值为 True,可以使用书签。 但是,其他数据库产品可能不支持书签。 例如,不能在基于 Paradox 链接表(没有主键)的任何 Recordset 对象中使用书签。
示例
以下示例使用 Bookmark 和 Bookmarkable 属性,使用户可以对记录集中的记录加标记,稍后再返回到此记录。
Sub BookmarkX()
Dim dbsNorthwind As Database
Dim rstCategories As Recordset2
Dim strMessage As String
Dim intCommand As Integer
Dim varBookmark As Variant
Set dbsNorthwind = OpenDatabase("Northwind.mdb")
Set rstCategories = _
dbsNorthwind.OpenRecordset("Categories", _
dbOpenSnapshot)
With rstCategories
If .Bookmarkable = False Then
Debug.Print "Recordset is not Bookmarkable!"
Else
' Populate Recordset.
.MoveLast
.MoveFirst
Do While True
' Show information about current record and get
' user input.
strMessage = "Category: " & !CategoryName & _
" (record " & (.AbsolutePosition + 1) & _
" of " & .RecordCount & ")" & vbCr & _
"Enter command:" & vbCr & _
"[1 - next / 2 - previous /" & vbCr & _
"3 - set bookmark / 4 - go to bookmark]"
intCommand = Val(InputBox(strMessage))
Select Case intCommand
' Move forward or backward, trapping for BOF
' or EOF.
Case 1
.MoveNext
If .EOF Then .MoveLast
Case 2
.MovePrevious
If .BOF Then .MoveFirst
' Store the bookmark of the current record.
Case 3
varBookmark = .Bookmark
' Go to the record indicated by the stored
' bookmark.
Case 4
If IsEmpty(varBookmark) Then
MsgBox "No Bookmark set!"
Else
.Bookmark = varBookmark
End If
Case Else
Exit Do
End Select
Loop
End If
.Close
End With
dbsNorthwind.Close
End Sub