Part IV: Professional Database Development
866
LISTING 24.1
Using a Bookmark to Mark a Record
Public Sub BookmarkExample()
Dim rs As DAO.Recordset
Dim bk As Variant
Set rs = Workspaces(0).Databases(0).OpenRecordset( _
“tblContacts”, dbOpenTable)
‘Move to the first record in the database:
rs.MoveFirst
‘Print the position in the database:
Debug.Print rs.PercentPosition
‘Set the bookmark to the current record:
bk = rs.Bookmark
‘Move to the last record in the database:
rs.MoveLast
‘Print the position in the database:
Debug.Print rs.PercentPosition
‘Move to the bookmarked record:
rs.Bookmark = bk
‘Print the position in the database:
Debug.Print rs.PercentPosition
rs.Close
Set rs = Nothing
End Sub
Eliminating dead code and unused variables
Before distributing your application, remove any dead code (code that isn’t used at all) from your
application. You’ll often find entire procedures or even modules that once served a purpose but are
no longer called. Also, it’s quite common to forget to remove variable declarations after removing
code using the variables. By eliminating dead code and unused variables, you reduce the memory
your application uses and the time required to compile code at runtime.
Other things that you can do to increase the speed of your modules include opening any add-ins
that your application uses for read-only access and replacing procedure calls within loops with in-
line code. Also, don’t forget one of the most important items: Deliver your applications with the
modules compiled.
Increasing network performance
The single most important action that you can take to make sure that your networked databases
run at peak performance is to run Access and the application database on the user’s computer and
link tables to the shared network database. Running Access over the network is much slower than
running it locally.