• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Using CurrentDB()

Microsoft offers a shortcut you can use when creating an object variable that points to the current database. Using the CurrentDB() function, you do not need to first point at the workspace; nor do you need to issue the OpenDatabase method. Instead, you set the Database object variable equal to the result from the CurrentDB() function, as shown in Listing 14.48.

Listing 14.48. Printing the Version of the Database Object

Sub UseCurrentDBFunc()
    Dim db As dao.Database

    'Point the Database object at a reference to the current
    'database
    Set db = CurrentDb()

    'Print the version property of the database
    Debug.Print db.Version
End Sub


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint