473,790 Members | 2,561 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to Compact a "Table"

Does anyone know how to compact a table (only) ?

I'm using some code o move rows up & down in a continuous form & it
works fine, but after some usage the rows refuse to move up or down
until I compact the database. Then with no modifications to the code it
works well.

Any ideas anyone ?

Thx & Best Rgds,
Prakash.

Nov 13 '05 #1
5 5234
Prakash wrote:
Does anyone know how to compact a table (only) ?

I'm using some code o move rows up & down in a continuous form & it
works fine, but after some usage the rows refuse to move up or down
until I compact the database. Then with no modifications to the code it
works well.

Any ideas anyone ?

Thx & Best Rgds,
Prakash.

You cannot compact a table. It is an object in the database. You can
only compact the entire database.

Explain some more about what you are trying to accomplish (not what your
technique is) and maybe someone can find a better way to help you do it.

Bob
Nov 13 '05 #2

"Prakash" <si****@omantel .net.om> wrote in message
news:11******** **************@ g44g2000cwa.goo glegroups.com.. .
Does anyone know how to compact a table (only) ?

I'm using some code o move rows up & down in a continuous form & it
works fine, but after some usage the rows refuse to move up or down
until I compact the database. Then with no modifications to the code it
works well.

Any ideas anyone ?

Thx & Best Rgds,
Prakash.
try the following code . It will compact the database


Dim File_path As String
Dim Message As String
Dim title As String
Dim Default As String
Dim aaGetalUsers As Integer

' make sure that all forms are closed !!!!!!
' make sure that all users are logged out
On Error GoTo ErrJam
Dim ConnectStr As String
ConnectStr = CurrentDb.Table Defs("DbMaster1 ").Connect
ConnectStr = Mid([ConnectStr], InStr([ConnectStr], "database=" ) + 9)
Message = "Specify the Path and Database to compact. " ' Set prompt.
title = "Compacting of backend database " ' Set title.
Default = ConnectStr

File_path = InputBox(Messag e, title, Default)

Dim cNom1, cNom2, cNom3, cNom4, cNom5, cNom6, cNom7, cNomTotal, cNomDot As
Integer
Dim FileP, PrName As String
cNom1 = 0: cNom2 = 0: cNom3 = 0: cNom4 = 0: cNom5 = 0:
cNom6 = 0: cNom7 = 0
cNom1 = InStr(1, File_path, "\") ' 'find location of first '-'
If cNom1 <> 0 Then cNom2 = InStr(cNom1 + 1, File_path, "\") ' find the
second '-'
If cNom2 <> 0 Then cNom3 = InStr(cNom2 + 1, File_path, "\") ' find the
second '-'
If cNom3 <> 0 Then cNom4 = InStr(cNom3 + 1, File_path, "\") ' find the
second '-'
If cNom4 <> 0 Then cNom5 = InStr(cNom4 + 1, File_path, "\")
If cNom5 <> 0 Then cNom6 = InStr(cNom5 + 1, File_path, "\")
If cNom6 <> 0 Then cNom7 = InStr(cNom6 + 1, File_path, "\")

If cNom1 <> 0 Then cNomTotal = cNom1
If cNom2 <> 0 Then cNomTotal = cNom2
If cNom3 <> 0 Then cNomTotal = cNom3
If cNom4 <> 0 Then cNomTotal = cNom4
If cNom5 <> 0 Then cNomTotal = cNom5
If cNom6 <> 0 Then cNomTotal = cNom6
If cNom7 <> 0 Then cNomTotal = cNom7

cNomDot = InStr(1, File_path, ".")

FileP = Left$(File_path , cNomTotal)
' MsgBox FileP
PrName = Mid(File_path, cNomTotal + 1, cNomDot - cNomTotal - 1)
' MsgBox PrName

' Delete the previous backup file if it exists.
If Dir(FileP & PrName & ".bak") <> vbNullString Then
Kill FileP & PrName & ".bak"
End If

' Compact the database to a temp file.

DBEngine.Compac tDatabase FileP & PrName & ".mdb", FileP & PrName &
"Temp.mdb", , , PWD=yourBackend Password"

' Rename the current database as backup and rename the temp file to
' the original file name.
Name FileP & PrName & ".mdb" As FileP & PrName & ".bak"
Name FileP & PrName & "Temp.mdb" As FileP & PrName & ".mdb"

Exit_ErrJam:
Exit Sub

ErrJam:
If Err.Number = 3044 Then
MsgBox " Not a valid path. Make sure the path name is spelled
correctly and that you are connected to the server on which the file
reside."
Resume Exit_ErrJam
ElseIf Err.Number = 94 Then
Resume Exit_ErrJam
ElseIf Err.Number = 3356 Then
MsgBox " Someone is still logged in. can't continue!"
Resume Exit_ErrJam
Else
MsgBox "Error in RepairForm. " & _
"Its number and description are " & _
Err.Number & ": " & Err.Description , vbCritical, _
"JAMTech email: su*****@jam.co. za"
Resume Exit_ErrJam
End If
Nov 13 '05 #3
On Mon, 25 Jul 2005 22:48:38 +0200, "alfred"
<al***********@ hotmail.com> wrote:

Did you write this code before you found out you can scan a string
from the end?
Something like:
for i=len(strPath) to 1 step -1
if mid$(strPath,i, 1) = "\" then
'etc.

Of course you should also handle the case where there is no \ in the
path. or the user hit Cancel.

But the larger issue is that having to compact is entirely
unreasonable, and we would want to figure out why this is, rather than
to offer a compact solution.

-Tom.


"Prakash" <si****@omantel .net.om> wrote in message
news:11******* *************** @g44g2000cwa.go oglegroups.com. ..
Does anyone know how to compact a table (only) ?

I'm using some code o move rows up & down in a continuous form & it
works fine, but after some usage the rows refuse to move up or down
until I compact the database. Then with no modifications to the code it
works well.

Any ideas anyone ?

Thx & Best Rgds,
Prakash.
try the following code . It will compact the database


Dim File_path As String
Dim Message As String
Dim title As String
Dim Default As String
Dim aaGetalUsers As Integer

' make sure that all forms are closed !!!!!!
' make sure that all users are logged out
On Error GoTo ErrJam
Dim ConnectStr As String
ConnectStr = CurrentDb.Table Defs("DbMaster1 ").Connect
ConnectStr = Mid([ConnectStr], InStr([ConnectStr], "database=" ) + 9)
Message = "Specify the Path and Database to compact. " ' Set prompt.
title = "Compacting of backend database " ' Set title.
Default = ConnectStr

File_path = InputBox(Messag e, title, Default)

Dim cNom1, cNom2, cNom3, cNom4, cNom5, cNom6, cNom7, cNomTotal, cNomDot As
Integer
Dim FileP, PrName As String
cNom1 = 0: cNom2 = 0: cNom3 = 0: cNom4 = 0: cNom5 = 0:
cNom6 = 0: cNom7 = 0
cNom1 = InStr(1, File_path, "\") ' 'find location of first '-'
If cNom1 <> 0 Then cNom2 = InStr(cNom1 + 1, File_path, "\") ' find the
second '-'
If cNom2 <> 0 Then cNom3 = InStr(cNom2 + 1, File_path, "\") ' find the
second '-'
If cNom3 <> 0 Then cNom4 = InStr(cNom3 + 1, File_path, "\") ' find the
second '-'
If cNom4 <> 0 Then cNom5 = InStr(cNom4 + 1, File_path, "\")
If cNom5 <> 0 Then cNom6 = InStr(cNom5 + 1, File_path, "\")
If cNom6 <> 0 Then cNom7 = InStr(cNom6 + 1, File_path, "\")

If cNom1 <> 0 Then cNomTotal = cNom1
If cNom2 <> 0 Then cNomTotal = cNom2
If cNom3 <> 0 Then cNomTotal = cNom3
If cNom4 <> 0 Then cNomTotal = cNom4
If cNom5 <> 0 Then cNomTotal = cNom5
If cNom6 <> 0 Then cNomTotal = cNom6
If cNom7 <> 0 Then cNomTotal = cNom7

cNomDot = InStr(1, File_path, ".")

FileP = Left$(File_path , cNomTotal)
' MsgBox FileP
PrName = Mid(File_path, cNomTotal + 1, cNomDot - cNomTotal - 1)
' MsgBox PrName

' Delete the previous backup file if it exists.
If Dir(FileP & PrName & ".bak") <> vbNullString Then
Kill FileP & PrName & ".bak"
End If

' Compact the database to a temp file.

DBEngine.Compac tDatabase FileP & PrName & ".mdb", FileP & PrName &
"Temp.mdb", , , PWD=yourBackend Password"

' Rename the current database as backup and rename the temp file to
' the original file name.
Name FileP & PrName & ".mdb" As FileP & PrName & ".bak"
Name FileP & PrName & "Temp.mdb" As FileP & PrName & ".mdb"

Exit_ErrJam:
Exit Sub

ErrJam:
If Err.Number = 3044 Then
MsgBox " Not a valid path. Make sure the path name is spelled
correctly and that you are connected to the server on which the file
reside."
Resume Exit_ErrJam
ElseIf Err.Number = 94 Then
Resume Exit_ErrJam
ElseIf Err.Number = 3356 Then
MsgBox " Someone is still logged in. can't continue!"
Resume Exit_ErrJam
Else
MsgBox "Error in RepairForm. " & _
"Its number and description are " & _
Err.Number & ": " & Err.Description , vbCritical, _
"JAMTech email: su*****@jam.co. za"
Resume Exit_ErrJam
End If


Nov 13 '05 #4
thx alfred & thx tom too. I'll post my code here in a couple of days
after a bit more studying & with some explanations as to the flow.

I've been using the back end database for nigh on 6 months without a
compact & no probs & now this small crazy bit.

I'll get back with the code asap.

Thx & Best Rgds,
Prakash.

Nov 13 '05 #5
It will be interesting to see how much it has grown over several months
without any compacting. I'd infer from your description that there is
considerable add-delete activity if you are moving records in a form...

Larry Linson
Microsoft Access MVP

"Prakash" <si****@omantel .net.om> wrote in message
news:11******** **************@ o13g2000cwo.goo glegroups.com.. .
thx alfred & thx tom too. I'll post my code here in a couple of days
after a bit more studying & with some explanations as to the flow.

I've been using the back end database for nigh on 6 months without a
compact & no probs & now this small crazy bit.

I'll get back with the code asap.

Thx & Best Rgds,
Prakash.

Nov 13 '05 #6

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

Similar topics

2
8688
by: Robin Tucker | last post by:
I have some code that dynamically creates a database (name is @FullName) and then creates a table within that database. Is it possible to wrap these things into a transaction such that if any one of the following fails, the database "creation" is rolledback. Otherwise, I would try deleting on error detection, but it could get messy. IF @Error = 0 BEGIN SET @ExecString = 'CREATE DATABASE ' + @FullName EXEC sp_executesql @ExecString
17
3890
by: black tractor | last post by:
HI there.. l was just wondering, if l place a "table" in the "editable region" of my template, will the text, graphics placed inside the this "table" MOVE BY ITSELF?? l mean, recently l had a "table" insert in my "editable region", have it placed in the "center" of the page.. while it display correctly on my browser, with setting at 1024x768 (IE6),
1
1457
by: avihaimar | last post by:
hello i have the code below: <html> <body> <table> <div id="div1" style="display :none"> <tr> <td> uuu </td>
4
1929
by: Nathan Benefield | last post by:
I currently have a spreadsheet tracking votes on legislation in a matrix type format. It is something like this Name Act1 Veto1 Act1A Jones yes No Yes Johnson Yes Yes Ex. Only with many more members and bills. I want to normalize this so that i can create reports by both Bill and by member - linking it to tables
5
1840
by: kiask2343 | last post by:
Ok before I get started let it be known I am the definition of a newbie when it comes to access and VBA. I know very little about access and nothing about VBA. I am in the Army and am tasked with making a maintenance program for medical equipment. I have the database, the query, the forms, and the reports. I was able to figure those out, but there is one thing that is beyond me. Ok I have three tables call them table "A" table "B" and...
2
7705
ramprabu
by: ramprabu | last post by:
Hello, I will give the sample code of html. Here first table only apply border 1 width. other tables are border 0. The problem is border=0 means border was not visible but it takes white border space. I want to remove this space. How can I solve? <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server">
0
5434
by: s.amann | last post by:
Hello, I get the following error when I try to insert data into a table. "SQL1477N Table "<table-name>" cannot be accessed. " The table was created with NOT LOGGED INITIALLY The import is done by a program written in C and using embedded SQL. It starts with ALTER TABLE myTable ACTIVATE NOT LOGGED INITIALLY WITH EMPTY TABLE. Then I prepare the statement and the inserts are done within a loop
2
6673
by: kilo | last post by:
Hey.. I need someone hwo can help me making my sql table.. I have no php skills. I have payed for a php program that shoud make dictation for people that have some problems reading danish.. with sound and text.. When I'm making the dictation with PHP I'm getting an error like this.: Query failed (SELECT word FROM repository): Table 'test_dig_dk.repository' doesn't exist the first one of the php, that I soud use for makeing the text is.. ...
3
10376
by: moltendorf | last post by:
I copied the files from my "test" database on my old server (MySQL was not running) to my new server ("./mysql/data/test" folder), and after starting the server, SHOW TABLES; shows all of the tables that are supposed to be there, but running a SELECT * FROM `configuration`; (for example) returns "test.configuration does not exist). I've tried the following repair statement since I'm not too familiar with backing up and restoring data. ...
0
9666
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
9512
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
10413
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9986
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7530
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
5422
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
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3707
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2909
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.