473,585 Members | 2,512 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DB Grows, possible to auto compact DB?

ChaseCox
294 Contributor
Hello All,

I was wondering if anyone had ever experienced this.

When ever I use my DB, it continues to get larger. Is there away to automatically compact the database upon closing or opening? Any help would be greatly apprecited.

If you need some more information, please let me know.
Apr 3 '07
53 4839
Denburt
1,356 Recognized Expert Top Contributor
strDBName ,strTempDB

strDBName is your database name
strTempDB merely a temporary db which will be deleted using the script.
Expand|Select|Wrap|Line Numbers
  1. Path = GetPath
  2. strTempDB = Path & "Comp0001.mde"
  3. strDBName = Path & "MyMDE.mde"
  4. Function GetPath
  5. ' Return path to the current script
  6. path = WScript.ScriptFullName  ' script file name
  7. GetPath = Left(path, InstrRev(path, "\"))
  8. End Function
  9.  
The above Function only works if it is in the same directory as the database.
Apr 3 '07 #11
ChaseCox
294 Contributor
My version of access does not recognize WSscript. and what is this vbcrlf Thanks again
Apr 3 '07 #12
Denburt
1,356 Recognized Expert Top Contributor
Sorry the following should be in the VBS script:

Expand|Select|Wrap|Line Numbers
  1. Path = GetPath
  2. 'Temporary db to be deleted once Compact is complete
  3. strTempDB = Path & "Comp0001.mde"
  4. 'Your .mdb or mde file name here
  5. strDBName = Path & "MyMDE.mde"
  6.  
  7. Function GetPath
  8. ' Return path to the current script
  9. path = WScript.ScriptFullName  ' script file name
  10. GetPath = Left(path, InstrRev(path, "\"))
  11. End Function
  12.  
Apr 3 '07 #13
ChaseCox
294 Contributor
I am not sure I know what that means.
Apr 3 '07 #14
Denburt
1,356 Recognized Expert Top Contributor
The following should be placed in a module in your DataBase:
http://www.thescripts.com/forum/post2482491-7.html


I use notepad for all my VBS stuff, When you save the file make sure the extension is somefile.vbs

Paste in the following and make your adjustments.
This should be at the top of the VBS script:
http://www.thescripts.com/forum/post2482534-11.html

Then this in the VBS script:

http://www.thescripts.com/forum/post2482509-9.html
Apr 3 '07 #15
NeoPa
32,566 Recognized Expert Moderator MVP
I tried this snippet before. But it can only be used on a DB you are not currently in. I need someway to compact on closing. Any thoughts on this? I will keep looking for compact on close.
Compact on Close was introduced in the next version (2K) :(
vbCrLf is a predefined string within VBA which is just a Carriage-Return / Line-Feed sequence.
As denburt says, the ability to Compact your current database depends on getting out of it first - hence his idea to use VBScript.
Apr 4 '07 #16
ChaseCox
294 Contributor
When I post the second item from your post:
Expand|Select|Wrap|Line Numbers
  1. Path = GetPath
  2. strTempDB = Path & "Comp0001.mde"
  3. strDBName = Path & "MyMDE.mde"
  4. Function GetPath()
  5. ' Return path to the current script
  6. Path = WScript.ScriptFullName  ' script file name
  7. GetPath = Left(Path, InstrRev(Path, "\"))
  8. End Function
  9.  
I get an error when I compile that says invalid outside procedure. Where should I put this exactly, does it matter what I call the module?

Also the .mde, is that the same as .mdb. which should I use?
Apr 5 '07 #17
ChaseCox
294 Contributor
I just now realized that I should paste
Expand|Select|Wrap|Line Numbers
  1. Path = GetPath
  2. strTempDB = Path & "Comp0001.mde" ... 
in a seperate script file, because that is what you said to do, and I just did not listen, oops. Sorry. Does it matter what I call it?

Also when I compile my Form code, it does not recognize wscript. any thoughts?
Apr 5 '07 #18
Denburt
1,356 Recognized Expert Top Contributor
That snippet of code should be in your VBS script not the database. Make sure the database and script are in the same location or that function will not work as expected.

See this post

Your database can be either a mdb or mde. When you are in an MDB you can create an MDE which is simply creating a copy of your database that is completely compiled a little quicker and your users can't go into the code.
Apr 5 '07 #19
ChaseCox
294 Contributor
Your database can be either a mdb or mde. When you are in an MDB you can create an MDE which is simply creating a copy of your database that is completely compiled a little quicker and your users can't go into the code.
Ok thanks. Any ideas about WScript?
Apr 5 '07 #20

Sign in to post your reply or Sign up for a free account.

Similar topics

5
4600
by: Charles McCaffery | last post by:
I have written a database with auto-numbering and now wish to remove alkl of my test data and set the auto-numbering back to one. How do I do this please? Charles McCaffery.
6
10218
by: Corepaul | last post by:
I am new to Access 2000. My operating system is Windows 2000. In the early stage of development I noticed something weird. On my form, I have a Command Button named "btnAlbumUp". The first time that I reference this button in VBA code, the Visual Basic Editor capitalizes the P changing btnAlbumUp.SetFocus to
0
3132
by: Willem | last post by:
Based on MK's TSI_SOON (http://www.trigeminal.com/)I've created a nifty little procedure that - whenever you compact you db you get an incremental backup copy. Given that you have a table with version information you get incremental backups on a per-version basis. SEE CODE BELOW Basic idea is: start TSISOON with the options: 1. "compact...
16
20468
by: John Baker | last post by:
Hi: I know this is a strange question, but I have inherited a system where files are copied and records re auto numbered (as an index field) )frequently, and I am wondering how high the number can go without the system crashing. An ancillary question is how one resets an auto number so that the sequence starts again at 1. In the case...
3
11220
by: trueblue7 | last post by:
I apologize if this question has been asked before... I'm trying to reset autonumber fields back to 1. The autonumber fields are part of the composite primary keys. I followed the MS help with a temp table and append query. I can change the number to anything but 1. I'm using Access XP and saving as 2000. Any help is appreciated.
1
7219
by: SQL Server | last post by:
Hi, The tempdb file on one of our servers grew very large and used all available disk space. This is SQL Server 2000 SP4. I have installed hotfix version 8.00.2187. I opened a profiler trace but can't still get to the root of the problem. Any help will be appreciated. Egbon *** Sent via Developersdex http://www.developersdex.com ***
20
9188
by: deepak | last post by:
Hi All, In C I heard the stack grows from top to bottom and heap from bottom to top. Is it compiler depend?
3
2168
by: Wayne L | last post by:
Ok now everyone has mentioned not to use auto number if it means anything to the user. My application uses the auto number for exporting only. I append the mastertbl column with my starting number of 0001(4 digits) (prior to populating the table). When information is imported and appended via a query to the mastertbl it will start with 0002 and...
3
2705
by: Fiddler2 | last post by:
I noticed that after running compact/repair, I have to recompile my code for the program not to break the next time I open it. What happens is the auto exec macro runs the main() module, then hangs with the second line of code highlighted. No error message, just hangs. If I stop it and recompile the code, it runs again. Does anyone know anything...
0
7908
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7836
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8199
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8336
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6606
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5710
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5389
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3863
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1175
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.