• 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 to 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 15.11.

Listing 15.11. Listing the errors in the current database.

Sub UseCurrentDBFunc()
    Dim db As DATABASE
    Dim erx as Error

    Set db = CurrentDB()
    Debug.Print db.Version
    For Each erx in db.Errors
        Debug.print erx.Number, erx.Description
    Next
End Sub


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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