Close database on close form

  • Thread starter Thread starter Kevin Sprinkel
  • Start date Start date
K

Kevin Sprinkel

Hi, all.

I'm trying to close the database when the initial form is
closed with:

Private Sub Form_Close()
Dim db As Database
Set db = CurrentDb()
db.Close
End Sub

Access says "user-defined type not defined", which I
presume means I need to add a Reference. Anyone know
which one?

Thanks.
Kevin Sprinkel
 
Try:
DoCmd.Quit

The problem with the type is a reference issue, and the Database type is
supplied by the "DAO 3.6 Library" More information on references:
http://allenbrowne.com/ser-38.html
However, closing the object variable does not close the instance of Access,
so that is not a useful direction.
 
You will need to refrence the DAO object library. It
should appear as Microsoft DAO 3.6 Object Library in the list.

Hope This Helps
Gerald Stanley MCSD
 
Use DoCmd.Qui

----- Kevin Sprinkel wrote: ----

Hi, all

I'm trying to close the database when the initial form is
closed with

Private Sub Form_Close(
Dim db As Databas
Set db = CurrentDb(
db.Clos
End Su

Access says "user-defined type not defined", which I
presume means I need to add a Reference. Anyone know
which one

Thanks
Kevin Sprinke
 
Try docmd.qui
or if you prefer to quit Access entirely try application.qui

Basi

----- Kevin Sprinkel wrote: ----

Hi, all

I'm trying to close the database when the initial form is
closed with

Private Sub Form_Close(
Dim db As Databas
Set db = CurrentDb(
db.Clos
End Su

Access says "user-defined type not defined", which I
presume means I need to add a Reference. Anyone know
which one

Thanks
Kevin Sprinke
 
There's several useful nuances to this; thanks to all of
you for making me aware of them.

Best regards.
Kevin Sprinkel
 
Back
Top