Close database on close form

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
 
A

Allen Browne

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.
 
G

Gerald Stanley

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
 
H

Howard Brody

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
 
B

Basil

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
 
K

Kevin Sprinkel

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

Best regards.
Kevin Sprinkel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top