Hy to all
I'm using access 2003 (11.5614.5606)
I have a database called "form" that I imported all my forms on it and I linked tables of "forms " into another database called "tables" what I need is any method using VB to compact and repair "table" database from a form in "form" database
is that possible guys ????
2 2234 NeoPa 32,556
Expert Mod 16PB
I have a CommandButton (cmdCompact) on a form (frmCompact).
I'll copy in the code but beware, as it refers to other procedures I've had to chop and change it somewhat.
To follow shortly when I've done the fixing.
NeoPa 32,556
Expert Mod 16PB
Here's the code : - Option Compare Database
-
Option Explicit
-
-
Private Const conJob As String = "Compact Databases"
-
Private Const conStub As String = "Compact"
-
Private Const conWarning As String = _
-
"You are about to %S all Access Databases that this " & _
-
"database links to." & vbCrLf & vbCrLf & _
-
"If you are happy to continue press OK, " & _
-
"otherwise press Cancel to abort."
-
-
Private Sub cmdCompact_Click()
-
Dim strWork As String, strDBs As String
-
Dim intPos As Integer, intLen As Integer
-
Dim tblThis As TableDef
-
-
strWork = Replace(conWarning, "%S", conStub)
-
If MsgBox(Prompt:=strWork, _
-
Buttons:=vbQuestion Or vbOKCancel, _
-
Title:=conJob) <> vbOk Then Exit Sub
-
-
Call DoCmd.SetWarnings(False)
-
strDBs = ""
-
For Each tblThis In CurrentDb.TableDefs
-
strWork = ConnectName(tblThis.Name)
-
If strWork > "" Then
-
strWork = """" & strWork & """" & vbCrLf
-
If InStr(1, strDBs, strWork) = 0 Then _
-
strDBs = strDBs & strWork
-
End If
-
Next tblThis
-
intPos = 2
-
Do
-
intLen = InStr(intPos, strDBs, vbCrLf) - intPos - 1
-
If CompactDb(Mid(strDBs, intPos, intLen)) Then
-
intPos = intPos + intLen + 4
-
Else
-
strDBs = Left(strDBs, intPos - 2) & _
-
Mid(strDBs, intPos + intLen + 3)
-
End If
-
Loop Until intPos > Len(strDBs)
-
strWork = "The following databases were compacted:%L%D"
-
strWork = Replace(strWork, "%L", vbCrLf)
-
strWork = Replace(strWork, "%D", strDBs)
-
Call MsgBox(Prompt:=strWork, Buttons:=vbInformation, Title:=conJob)
-
Call DoCmd.SetWarnings(True)
-
End Sub
Sign in to post your reply or Sign up for a free account.
Similar topics
by: KEVIN97810 |
last post by:
Hello to all,
Assume my mdb name is Cust.MDB. I want to compact & repair
the same Cust.MDB when the user exit the program. Is there a way you can do it
in code behind the EXIT button. I am...
|
by: Paolo |
last post by:
Hi,
I am trying to compact and repair my database, however every time I try it
comes up a message saying: Table: "TempMSysAccessObject already exists",
whenever I try to look for this table I...
|
by: Wayne |
last post by:
Does "Compact On Close" do a "Compact and Repair" or just a compact.
Is a compact necessary (or at least a good idea) on a regular basis,
say weekly, for a database that has several hundred records...
|
by: Mark G. King |
last post by:
I have Access 2003 SP2.
When I open any database annd choose Tools / Database Utilities the menu
item Compact And Repair is missing.
I have re-installed Office 2003 using Detect and Repair but...
|
by: Ron |
last post by:
Hi All,
Using WinXP pro/Access 2000.
I have a database that's been used for about 5 months. Transferred lots of
data from a dos based program, then the users have been using it for that 5...
|
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...
|
by: RZ15 |
last post by:
Hi,
I was working on a query this morning and everything was working fine. Some time in the last half hour, I used the Compact & Repair Database feature. After that, when I went to open the query...
|
by: Bizmark |
last post by:
Access2003,
Windows XP Pro OEM user OS,
Windows Sever 2000 server OS.
Not-so-recently I inherited 3 Access DB's from another company merging with our own. Our own system works off of SQL...
|
by: zufie |
last post by:
When I Repair/Compact my Access databse. I get icons/copies of a
database named db1.mdb, db2.mdb, db3.mdb, etc...
How else may I repair this database?
Thanks!,
Zuf
|
by: Bob Alston |
last post by:
For those of you that have replicated databases, how often to you
compact and repair them?
Also what mathod do you use if you do this on an automated way?
How do you make sure that the...
|
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
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
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...
|
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,...
|
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: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
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,...
| |