473,403 Members | 2,323 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,403 software developers and data experts.

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 5192
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.googlegr oups.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.TableDefs("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(Message, 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.CompactDatabase FileP & PrName & ".mdb", FileP & PrName &
"Temp.mdb", , , PWD=yourBackendPassword"

' 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.googleg roups.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.TableDefs("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(Message, 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.CompactDatabase FileP & PrName & ".mdb", FileP & PrName &
"Temp.mdb", , , PWD=yourBackendPassword"

' 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.googlegr oups.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
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...
17
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...
1
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
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 ...
5
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...
2
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...
0
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...
2
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...
3
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...
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
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...
0
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...

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.