473,607 Members | 2,674 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to compact & Repair Back-end from Front-end

Hi folks,

Somewhere, I recently saw an article header titled:

"How to compact and Repair a back-end Access db from the front-end
using VBA" or words to that effect.

Now that I need it, I cannot find it. Does anyone know were to find
such an article?

Thanks
Nov 13 '05 #1
5 17651
Lauren Wilson wrote:
Hi folks,

Somewhere, I recently saw an article header titled:

"How to compact and Repair a back-end Access db from the front-end
using VBA" or words to that effect.

Now that I need it, I cannot find it. Does anyone know were to find
such an article?

Thanks


dbEngine.Compac tDatabase "PathToSour ce" "PathToDestinat ion"

--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
Nov 13 '05 #2
Lauren,

Are you still looking for a calendar report? Leave your email and I will
send you a screenshot of what I
have.

Access Resource

"Lauren Wilson" <no****@private .com> wrote in message
news:0l******** *************** *********@4ax.c om...
Hi folks,

Somewhere, I recently saw an article header titled:

"How to compact and Repair a back-end Access db from the front-end
using VBA" or words to that effect.

Now that I need it, I cannot find it. Does anyone know were to find
such an article?

Thanks

Nov 13 '05 #3

Yes.

Send it to my partners: su*****@lmc.bz

Thanks
On Tue, 24 May 2005 13:11:22 GMT, "Access Resource"
<ac************ @discussions.mi crosoft.com> wrote:
Lauren,

Are you still looking for a calendar report? Leave your email and I will
send you a screenshot of what I
have.

Access Resource

"Lauren Wilson" <no****@private .com> wrote in message
news:0l******* *************** **********@4ax. com...
Hi folks,

Somewhere, I recently saw an article header titled:

"How to compact and Repair a back-end Access db from the front-end
using VBA" or words to that effect.

Now that I need it, I cannot find it. Does anyone know were to find
such an article?

Thanks


Nov 13 '05 #4
Bri
Lauren Wilson wrote:
Hi folks,

Somewhere, I recently saw an article header titled:

"How to compact and Repair a back-end Access db from the front-end
using VBA" or words to that effect.

Now that I need it, I cannot find it. Does anyone know were to find
such an article?

Thanks


Lauren,

Rick has already mentioned the key piece needed but there are a few
things that you need to know about to make this work.

If the Backend is being accessed then the CompactDatabase method will
fail as it cannot get Exclusive use of it. Your code will need to trap
this error. Also, if your frontend maintains any attachments to the
backend (ie first form open opens a recordset on the backend to force
the backend ldb file to remain for the session - a known trick to
speedup FE-BE setups) you will need to have your code close them before
the compact (and I suppose reopen them after). In some situations, you
may need to 'unlink' the tables from the BE (test without first as it is
much easier to code). The newly compacted backend then needs to replace
the old backend. I usually leave it around as a backup (renamed). Below
my sig is a function I use as a starting place. I pass to it the name of
a table in the BE so it can get the name of the BE from its connection
string.

--
Bri

My code, watch for wrap.

Function Compactdb(Table Name As String) As Boolean
On Error GoTo Err_CompactDB

'If Tables are always connected then use commented code
'Dim Connections() As String
Dim i, j As Integer
Dim tbl As TableDef
Dim stFileName

DoCmd.Hourglass True

stFileName = db.TableDefs(Ta bleName).Connec t
stFileName = Mid(stFileName, InStr(stFileNam e, "=") + 1)

'If Tables are always connected then use commented code
'i = db.TableDefs.Co unt
'ReDim Connections(i)
'j = 0
'For Each tbl In db.TableDefs
' Connections(j) = tbl.Connect
' If Left(tbl.Name, 4) <> "Msys" Then
' tbl.Connect = ""
' tbl.RefreshLink
' End If
' j = j + 1
'Next

DBEngine.Compac tDatabase stFileName, stFileName & "TMP"
If Dir(stFileName & ".BCK") <> "" Then _
Kill stFileName & ".BCK"
Name stFileName As stFileName & ".BCK"
Name stFileName & "TMP" As stFileName
If Dir(stFileName & "TMP") <> "" Then _
Kill stFileName & "TMP"

Compactdb = True

'If Tables are always connected then use commented code
'j = 0
'For Each tbl In db.TableDefs
' If Left(tbl.Name, 4) <> "Msys" Then
' tbl.Connect = Connections(j)
' tbl.RefreshLink
' End If
' j = j + 1
'Next

Exit_Compactdb:
DoCmd.Hourglass False
Exit Function

Err_CompactDB:
DoCmd.Hourglass False
Compactdb = False
If Err.Number = 3356 Then
MsgBox "The database is currently being used by another User. " & _
"You can only Compact the Database if you are the only person " & _
"using it." & vbCr & _
vbCr & "Please try again later.", vbExclamation, & _
"Database in Use by Another User"
Else
MsgBox Err.Description
End If
Resume Exit_Compactdb

End Function

Nov 13 '05 #5

Thanks a lot Bri!
On Tue, 24 May 2005 17:33:11 GMT, Bri <no*@here.com > wrote:
Lauren Wilson wrote:
Hi folks,

Somewhere, I recently saw an article header titled:

"How to compact and Repair a back-end Access db from the front-end
using VBA" or words to that effect.

Now that I need it, I cannot find it. Does anyone know were to find
such an article?

Thanks


Lauren,

Rick has already mentioned the key piece needed but there are a few
things that you need to know about to make this work.

If the Backend is being accessed then the CompactDatabase method will
fail as it cannot get Exclusive use of it. Your code will need to trap
this error. Also, if your frontend maintains any attachments to the
backend (ie first form open opens a recordset on the backend to force
the backend ldb file to remain for the session - a known trick to
speedup FE-BE setups) you will need to have your code close them before
the compact (and I suppose reopen them after). In some situations, you
may need to 'unlink' the tables from the BE (test without first as it is
much easier to code). The newly compacted backend then needs to replace
the old backend. I usually leave it around as a backup (renamed). Below
my sig is a function I use as a starting place. I pass to it the name of
a table in the BE so it can get the name of the BE from its connection
string.


Nov 13 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3271
by: pwh777 | last post by:
I have three databases. DB1 has a button on a form. When I click that button, I want to import all the objects from DB2 to DB3 (just as you would if you would chose the File > Get External Data > Import menu option). Then I want to Compact and Repair DB3. I want to do this all by pushing the button in DB1. Is this possible?
3
5563
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 cannot find it anywhere... Any clues... Already went into the help file and nothing... Also try to copy my database and the same message comes up
6
3064
by: GaryDave | last post by:
My school registration database has not been quite right after a recent compact and repair (done while I was away). Though most of the many forms and subforms are working normally, one form in particular will no longer allow new entries into the subform - the recordset of the underlying query is no longer updatable. The subform in question enters the identity and other vital info for children whose parent's ID provides the FK, linking...
2
1869
by: ApexData | last post by:
Hello I have finally completed an application and am preparing to install it on a network of 10 users. The application will be split FE/BE. The application has its own login, which controls the users ability to either ViewOnly or FullRights. Using Access2K. 20MB Database. My questions pertain to CompactOnClose:
2
3126
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 this hasn't helped. I have other versions of Office loaded on my machine including Access 97, Access 2000, Access 2002 and Access 2003.
3
2168
by: G Gerard | last post by:
Hello The more I use an application ( an mdb) created using MSAccess I notice that the Byte size of the application keeps on increasing. Once in a while I do a Compact and Repair Database (under Tools in MSAccess) on the application and the size then returns to normal.
1
2251
by: ncsthbell | last post by:
I have an Access 2000 database (running on Windows XP) that is used as a model and each user grabs a copy of this and puts onto their own drive. I have had 2 folks have issues with it lately. When they try to open it, the application does not fully open. What you see is a blank grey form with the dark blue title bar at the top with the appliation title. The 'main' form that is set on the startup properties does not come up. Everything is...
4
2731
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 automated process is successful and if not, what process of notification is used? Bob
9
3315
by: Timmy! | last post by:
A2003 on Win XP Pro. A number of very stable apps I have are lately sometimes crashes when I do a compact & repair, especially when I hold the shift key to do so. When this starts happening, I usually turn off or restart my computer. Sometimes this stops the crashing, sometimes it doesn't. I'm really not sure why this is happening, I've never experienced it before.
4
2623
by: shalskedar | last post by:
The Compact & Repair option is not working on 1 of the computers .The Operating system used is Windows XP. In the Database,when the Compact & Repair option is used it creates a separate file as db1.mdb. Whereas other computers this option works fine..it no longer creates db1.mdbs separately. Does the computer which is not able to do Compact & Repair require any specific setting.. Can anyone Plz help me with some solution for this .
0
8049
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7985
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8463
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
6803
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5997
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3953
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4013
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1574
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1316
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.