473,395 Members | 1,815 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,395 software developers and data experts.

Code completion / compact DB from code / slice data ???

Hello All,

I've written code in a test database with test data. Everything seems
to be working except compact database in VB code per
http://www.mvps.org/access/general/gen0041.htm. The reason I say this
is the auto number fields are NOT being reset to zero. I delete the
data from tables with action delete queries, then call the compact DB
code which is followed by importing data to tables and subsequent
append queries to other tables. I have received intermittent error
messages on the compact DB code a small percentage of the test runs.
However I can tell the database is being compacted because I've
manually imported the data followed by running the code. Each time the
DB is reduced to 50% of the original size after doubling up the data
with the manual import. This leads me to believe that code is not
finishing before the next line is being run in VB. The reason I say
this the auto number field is not reset even though the import & append
queries are run after the compact DB.

The whole purpose of imports and append queries is to insure that the
critical text field is a certain length when comparing 3 different
sources of data which sets up the 'flag' field. The critical text
field hold numeric information which may have leading zeros. I set up
length of the critical text field with an append query with
'ConNo_x:format(txtConNo_x, "00000000")' for an expression in the
append query. The relationship of the 3 sources can best be summarized
below.

Source critical field characteristics flag
-------- -------------- ----------------------- ----

source 1 txtConNo1 none = to source 2 "A"

source 2 txtConNo2 none = to source 1 "A"

source 3 txtConNo3 some = to source 1 or 2 "A"

source 3 txtConNo3 none = to source 1 or 2 "B"
I accomplish this by setting up a form with 3 command buttons to
import the 3 sources of data. The import of the 3rd source checks the
number of records in source 1 and 2, and exits if either have no
records which insures setting up flag "B". I wanted to compact the
database because of the amount of data that is imported from Excel
files, and the compact keeps the DB at the appropriate size. The
problem with the compact DB is that the form is closed. The form won't
open when called from VB code after the compact even though other
append queries appear to be working after the compact DB.

My questions are as follows:

How can I insure code has completed execution before the next line is
executed?

Any ideals why the auto number fields are not being reset to 0 after
the compact?

How can I get the form to open after the compact of the database?

TIA!
I've included the code below:
============================>Import Form>====================
Option Compare Database
Option Explicit

Private Sub cmdImp_Set1_Click()

Dim db As DAO.Database

Set db = CurrentDb()

db.Execute "qdel_Set1_No_Pct_Date", dbFailOnError

db.Execute "qdel_Set1_ContNo_8Char", dbFailOnError

Call CompactDB

DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel8, _
"tbl_Set1_No_Pct_Date", _
"X:\My Documents\FileRef\Excel\RandomNo_3_sets.xls", _
True, "Set1_No_Pct_Date"

db.Execute "qap_Set1_ContNo_8Char", dbFailOnError

Call OpenImportFrm

Set db = Nothing
End Sub

Private Sub cmdImp_Set2_Click()
Dim db As DAO.Database

Set db = CurrentDb()

db.Execute "qdel_Set2_No", dbFailOnError

db.Execute "qdel_Set2_ContNo_8Char", dbFailOnError

Call CompactDB

DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel8, _
"tbl_set2_No", _
"X:\My Documents\FileRef\Excel\RandomNo_3_sets.xls", _
True, "set2_No"

db.Execute "qap_Set2_ContrNo_8Char", dbFailOnError

Call OpenImportFrm

Set db = Nothing
End Sub

Private Sub cmdImp_Set3_Click()

Dim db As DAO.Database

Dim rst1 As DAO.Recordset, rst2 As DAO.Recordset

Set db = CurrentDb()

Set rst1 = db.OpenRecordset("tbl_Set1_ContNo_8Char") ', dbOpenTable

Set rst2 = db.OpenRecordset("tbl_Set2_ContNo_8Char")

If rst1.RecordCount = 0 Or rst2.RecordCount = 0 Then

MsgBox ("You must import set 1 & 2 before set 3")

Exit Sub

End If
db.Execute "qdel_Set3_No", dbFailOnError

db.Execute "qdel_Set3_ContrNo_8Char_step1", dbFailOnError

db.Execute "qdel_Set3_ContrNo_8Char_step2", dbFailOnError

Call CompactDB

DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel8, _
"tbl_Set3_No", _
"X:\My Documents\FileRef\Excel\RandomNo_3_sets.xls", _
True, "Set3_No"

db.Execute "qap_Set3_ContrNo_8Char_step1", dbFailOnError

db.Execute "qap_Set3_ContrNo_8Char_step2", dbFailOnError

Set db = Nothing

Call OpenImportFrm

End Sub
============================<Import Form<====================

`````````````````````````````````````````````````` ```````````

============================>Public Modules>=================
Option Compare Database
Option Explicit

Public Sub CompactDB()

CommandBars("Menu Bar"). _
Controls("Tools"). _
Controls("Database utilities"). _
Controls("Compact and repair database..."). _
accDoDefaultAction

End Sub

Public Sub OpenImportFrm()
DoCmd.OpenForm "frmImport"
End Sub
============================<Public Modules<=================

--
Best Regards,
Greg Strong
--
Regards,

Greg Strong
Nov 13 '05 #1
2 2438
On Sat, 28 May 2005 22:41:15 GMT, Greg Strong <NoJunk@NoJunk4U˛.com> wrote:
The reason I say this
is the auto number fields are NOT being reset to zero.


I should have stated they are not being reset because technically the auto
number fields by default start with 1.

--
Regards,

Greg Strong
Nov 13 '05 #2
On Sat, 28 May 2005 22:41:15 GMT, Greg Strong <NoJunk@NoJunk4U˛.com> wrote:
I've written code in a test database with test data. Everything seems
to be working except compact database in VB code per
http://www.mvps.org/access/general/gen0041.htm. The reason I say this
is the auto number fields are NOT being reset to zero. I delete the
data from tables with action delete queries, then call the compact DB
code which is followed by importing data to tables and subsequent
append queries to other tables.


Well I've changed the code. I now include the compact db code per
http://www.mvps.org/access/general/gen0041.htm at the end of a procedure and
all the auto number fields are reset.

There must be an issue when the compact database code is followed by importing
of data via TransferSpreadsheet to tables with the auto number fields.

--
Regards,

Greg Strong
Nov 13 '05 #3

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

Similar topics

15
by: Roberto A. F. De Almeida | last post by:
I found that when using negative indices, the slice object passed to __getitem__ depends on the number of slices. An example to clarify: class a: def __getitem__(self, index): return index ...
2
by: Dave Bazell | last post by:
I have a multidimensional array, say 20 x 6, and I want to take a subset of the rows. I have an index array @indx=(1,3,12,17) for example, and what I want to say is @new_array = $data I know...
15
by: christopher diggins | last post by:
Here is some code I wrote for Matrix multiplication for arbitrary dimensionality known at compile-time. I am curious how practical it is. For instance, is it common to know the dimensionality of...
3
by: Trevor Hughes | last post by:
Hello All I have a database (Access 2000, running on Win 2000), which suffers from bloat over a period of time. In order to solve the problem I set the option to compact on exit. This however...
6
by: owengoodhew | last post by:
Hi, I am responsible for maintaining an MS Access 97 Database that reliably becomes corrupt following a compact......... About the Database: The database is made up of three linked databases,...
23
by: Antoon Pardon | last post by:
Now slices are objects in python, I was wondering if slice notation will be usable outside subscribtion in the future. Will it ever be possible to write things like: a = 4:9 for key, value in...
7
by: Alexandre Guimond | last post by:
Hi all, i'm trying to deepcopy a slice object but i get the following error. Does anyone know a workaround? ActivePython 2.4.3 Build 12 (ActiveState Software Inc.) based on Python 2.4.3 (#69,...
0
by: Tor Erik Soenvisen | last post by:
Hi, all I would like some feedback on a multithreaded HTTP server I've written. The server serves python-scripts by dynamically loading scripts in the same directory as itself. When a request is...
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...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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,...

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.