473,386 Members | 1,810 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Compact / Compress Access File using code

I have just come back to coding after a break of 12 months, as you know remebering wat u knew can be hard, i created a macro or code that compressed another database (renamed to temp, then copied back to original name) so that the user could maintain the size as required but for the life of me i cant find the file i created, can u help please.
Nov 24 '06 #1
5 2498
NeoPa
32,556 Expert Mod 16PB
Are you asking for help finding a file stored on your system?
If not, I'm not sure what you mean.
Perhaps you could clarify.
Nov 24 '06 #2
Are you asking for help finding a file stored on your system?
If not, I'm not sure what you mean.
Perhaps you could clarify.

No sorry, just that if you know the method / code that allows me to compact another file from a macro / database, i.e compact closed file A from code within open file B. hope this helps explain what i need.
Nov 24 '06 #3
NeoPa
32,556 Expert Mod 16PB
I've got you.
I'll post it here when I've found it - shouldn't be too long.
Nov 24 '06 #4
NeoPa
32,556 Expert Mod 16PB
This is an example function that I use.

Expand|Select|Wrap|Line Numbers
  1. 'CompactDb compacts a remote Access database.
  2. Public Function CompactDb(ByVal strDB As String, _
  3.                           Optional strPW As String = "") As Boolean
  4.     Dim strNewDB As String, strLocale As String
  5.  
  6.     On Error GoTo ErrorCDB
  7.     strNewDB = Replace(strDB, ".Mdb", "New.Mdb")
  8.     Call Echo(True, "Compacting '" & strDB & "'.")
  9.     If strPW <> "" Then strLocale = ";pwd=" & strPW
  10.     If Exist(strNewDB) Then Kill strNewDB
  11.     Call DBEngine.CompactDatabase(SrcName:=strDB, _
  12.                                   DstName:=strNewDB, _
  13.                                   DstLocale:=strLocale, _
  14.                                   SrcLocale:=strLocale)
  15.     Kill strDB
  16.     Name strNewDB As strDB
  17.     Call Echo(True, "'" & strDB & "' compacted.")
  18.     CompactDb = True
  19.     Exit Function
  20.  
  21. ErrorCDB:
  22.     CompactDb = False
  23. End Function
  24.  
  25. 'Exist returns true if strFile exists.
  26. '22/05/2003 Rewritten with better code.
  27. '20/05/2005 Added finding of R/O, System & Hidden files
  28. Public Function Exist(strFile As String, _
  29.                       Optional intAttrib As Integer = &H7) As Boolean
  30.     Exist = (Dir(PathName:=strFile, Attributes:=intAttrib) <> "")
  31. End Function
Nov 24 '06 #5
This is an example function that I use.

Expand|Select|Wrap|Line Numbers
  1. 'CompactDb compacts a remote Access database.
  2. Public Function CompactDb(ByVal strDB As String, _
  3.                           Optional strPW As String = "") As Boolean
  4.     Dim strNewDB As String, strLocale As String
  5.  
  6.     On Error GoTo ErrorCDB
  7.     strNewDB = Replace(strDB, ".Mdb", "New.Mdb")
  8.     Call Echo(True, "Compacting '" & strDB & "'.")
  9.     If strPW <> "" Then strLocale = ";pwd=" & strPW
  10.     If Exist(strNewDB) Then Kill strNewDB
  11.     Call DBEngine.CompactDatabase(SrcName:=strDB, _
  12.                                   DstName:=strNewDB, _
  13.                                   DstLocale:=strLocale, _
  14.                                   SrcLocale:=strLocale)
  15.     Kill strDB
  16.     Name strNewDB As strDB
  17.     Call Echo(True, "'" & strDB & "' compacted.")
  18.     CompactDb = True
  19.     Exit Function
  20.  
  21. ErrorCDB:
  22.     CompactDb = False
  23. End Function
  24.  
  25. 'Exist returns true if strFile exists.
  26. '22/05/2003 Rewritten with better code.
  27. '20/05/2005 Added finding of R/O, System & Hidden files
  28. Public Function Exist(strFile As String, _
  29.                       Optional intAttrib As Integer = &H7) As Boolean
  30.     Exist = (Dir(PathName:=strFile, Attributes:=intAttrib) <> "")
  31. End Function

Many thanks - i appreciate your help and expertise
Nov 24 '06 #6

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

Similar topics

0
by: Tony | last post by:
Hello, Any assistance would be appreciated: As the subject suggests I am trying to gunzip files using the Compress::Zlib module. The following is basically the code that I am working with: ...
15
by: Matt Kruse | last post by:
I am far from a PHP expert, and I've been struggling to create a function which will take a javascript .js file and "compact" it as much as possible. Meaning, remove all comments and unnecessary...
1
by: Sue | last post by:
For lob data is it a good idea to both compact and apply system compression? I understand compact can reduce performance when updating but any disadvantages of using compress? Will it help to save...
1
by: smitty mittlebaum | last post by:
I have a strange problem that has reared its ugly head in the last few weeks. I have the option "Compact on Close" (Tools, Options, General tab) enabled on my development machine. I did this...
6
by: MLH | last post by:
I just used Tools / Database Utilities / Compact Database in Access 97 for the first time. Unlike Access 2.0, it does not ask me to furnish a filename for it to compact into. It just launched...
6
by: Champika Nirosh | last post by:
Hi, I have two machine where I needed to have a extended TCP/IP protocol to make the link between the two machines Mean,I need to write a application that compress every data the machine send...
9
by: Ron | last post by:
New discovery. If I take a perfectly good database, and "compact/repair" on it with Access 2000 (seems to be at multiple sites--I've tried it with my system here, at another office on an...
29
by: Neil | last post by:
I would like to compact on close only if the database size goes over a certain amount, rather than each time. Thus, I'd like to check the file size and then perform the compact through code as the...
13
by: OldBirdman | last post by:
Access has an option for Compact on Close. Very good, as that should stop a major increase in size every time any .mdb file is used by Access. My question is, Is this safe? It used to be that I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
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...

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.