ACC1x: Trapping for Library Being Opened Before Database

Last reviewed: June 8, 1997
Article ID: Q109738
The information in this article applies to:
  • Microsoft Access versions 1.0, 1.1

SUMMARY

If you try to open a Microsoft Access library without first opening a database, the following error message is displayed:

   A Run-Time error occurred in Database: <Library Name>.
   You don't have permission to view the Modules in this Database.

This article discusses a technique for handling this situation using error trapping in Access Basic.

This article assumes that you are familiar with Access Basic and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information on Access Basic, please refer to the "Introduction to Programming" manual.

MORE INFORMATION

You can have a function in your Library determine whether a database is open by trapping for an error. For example, if a function in the library tries to open a form without a database first being opened, error number 2046 will be returned with the error message "Command Not Available: OpenForm."

You can trap this error message and display a more useful error message using the method demonstrated in the following sample error handler:

   On Error GoTo Errhand

   Errhand:
      'Display error number with error meaning
      MsgBox "Error # - " & Str(Err) & " - " & Error$

      If Err = 2046 Then
         'Display user-customized error message
         MsgBox "Please open a database first"
         Exit Function
      End If

REFERENCES

Microsoft Access "Introduction to Programming," version 1.0, Chapter 6, "Handling Run-Time Errors," pages 69-78

For more information on libraries, search for "library databases" then "Customizing MSACCESS.INI Settings" using the Microsoft Access Help menu.


Keywords : kberrmsg kbprg MdlLib PgmErr
Version : 1.0 1.1
Platform : WINDOWS
Hardware : X86
Issue type : kbinfo


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: June 8, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.