Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Compacting database

Posted on 2000-03-01
9
Medium Priority
?
202 Views
Last Modified: 2012-05-04
I'm using VB6 pro edition.

I try to compact my Access-database every time when I close my program.
Way I tryed to do it:

CompactDatabase App.Path & "/database.mdb", App.Path & "/newdatabase.mdb"
.
.

But when I do this vb gives me an error:
sub of function not defined...

What could be wrong? I remember that I have used this method sometimes before without any problems...

Thanks in advance!
0
Comment
Question by:majala
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 15

Expert Comment

by:cquinn
ID: 2571952
dbengine.compactdatabase
0
 

Author Comment

by:majala
ID: 2572062
Now I got an error:
(after using dbengine.compactdatabase)

Run-time error '424':
Object required
0
 
LVL 1

Accepted Solution

by:
pookytoo earned 150 total points
ID: 2572174
The function is part of DAO.
Reference DAO and VB will know the function.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 2

Expert Comment

by:sbmc
ID: 2574689
Try using \ instead of /
0
 

Author Comment

by:majala
ID: 2576142
Now I got an error which says that database is already open. I have DbGrid and Data controller in my form which is connected to that database. So I have close that connection before I can compact that database. How I close connection?
0
 
LVL 1

Expert Comment

by:pookytoo
ID: 2577100
   Dim db As String
    db = Data1.DatabaseName
    Data1.DatabaseName = ""
    Data1.Refresh
    DBEngine.CompactDatabase "olddb", "newdb"
    Data1.DatabaseName = db

where data1 is the name of your data controler.
0
 
LVL 1

Expert Comment

by:pookytoo
ID: 2577106
and refresh after setting back the databasename, of course.
That should save you.

0
 

Author Comment

by:majala
ID: 2579108
I tryed that your way to close a database and I got that same error I described in a previous message. Anyway I tryed this:
Data1.Database.close

and it worked.

0
 
LVL 2

Expert Comment

by:sbmc
ID: 2581705
Try using \ instead of /
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

876 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question