Access 97 to 2000 - Convert Data Only

D

Debra

I have an Access 97 application - runs in two databases -
forms/reports in one database linked to the other database
containing tables/data. We're updating to 2000. So I plan
to issue a CD-ROM which installs a 2000 version of the
code database and an empty 2000 table database.

Need to convert the 97 data to the 2000 'data' database.
One set of databases lives in C:\ProgramFiles\CSS and the
other will install into C:\ProgramFiles\CSS2000. What's
the best way to get this data over?

Do I ignore the empty 2000 'data' database, and have
everyone manually convert the 97 database and copy it into
the new directory (awkward - sure to screw up)? Or code
something into the AUTOEXEC to open recordsets and pull
data over (SQL statement? what? INSERT? - please, not a
million .ADDNEW/.FIELD stmts)? Please advise - only 2002
seems to have a programmatical solution to this. Thank
you!
 
G

Greg Kraushaar

You could cycle through the Tabledefs, and build an SQL for each on in
code. then run it.
if FileExists(strOldMDB) then
for easch tdf in db.tableDefs
StrSQL = "INSERT INTO " & tdf.Name & " IN " & strNewMDB _
& " SELECT * FROM " & tblBusObj & " in strOldMDB
ExecuteSQL strSQL
next tdf
Rename strOLDMDB, strOldBackupName
endif


Things to watch...
If you have enforced relationships, data will not transfer if the many
side comes up first in the tdf list
To resolve this, Save the tdfNames to a table, then define an order
manually. (On the development copy)
Then run the transfer SQLs from the table in order.(On each Machine)
Of course you could be more sophisticated walking the tables, and
determine the order form the relationships as defined in the DAO. But
for a one off conversion NAAAH!

Make sure you put in gotchas to get any hidden tables you might have.
Also avoid system tables and deleted tables. Can't remember if A97
just renamed tables to "Delete" them, or if that went out in A95

As usual with this sort of stuff, Test Test Test, then get someone
else to test as well

HTH
Regards Greg Kraushaar
Wentworth Falls Australia
(Do not email - the reply address is a Spam spoofer)
(If you really must, remove all UCase and numbers)
 
C

Chris Mills

The way I do an upgrade, if they install "MyApp2000" and previously had
"MyApp97", is that I have in the startup routine:
a) to detect a blank BE database ie no registration details
b) off to import table data from the old database, and give them a facility to
find the old database to import
c) using standard Access facilities, do you want to know general principles or
employ someone to write the whole thing for you?
d) The BE doesn't technically need converting at all, though it's best if it
is converted otherwise Repair/Compact might not work.

Ok, I'll write it, even though you are paid to be a developer. Some of this
may be more specific than you need.

(during startup)
If IsNull(rstConfig![Authorisation]) And IsNull(rstConfig!CompanyName) Then
Question = "New Installation" + Chr$(13) + Chr$(10) + Chr$(13) + Chr$(10)
+ "Do you wish to import data from a previous version of MyApp?"
gintResult = MsgBox(Question, MB_YESNO + MB_ICONINFORMATION +
MB_DEFBUTTON1, SYSNAME)
If gintResult = IDYES Then
DoCmd.Hourglass False
DoCmd.OpenForm "UpgradeImportDatabase", , , , , acDialog
DoCmd.Hourglass True
Set rstConfig = db.OpenRecordset("CONFIG", dbOpenDynaset)
End If
End If
....whatever

Form UpgradeImportDatabase:
(Select or find the db to import)

Private Sub cmdOK_Click()
On Error GoTo Err_cmdOK_Click
Dim MyWS As Workspace
Dim db As Database, dbs As Database
Dim Q As String
Dim strDBName As String

DoCmd.Hourglass True

If ([FileList].ListIndex = -1) Then GoTo Exit_cmdOK_Click

If Not IsNull([ImportDir]) Then
If Right([ImportDir], 1) <> "\" Then
[ImportDir] = [ImportDir] + "\"
End If
End If
strDBName = [ImportDir] & [FileList]

Set db = CurrentDb()
Set MyWS = DBEngine.Workspaces(0)
Set dbs = MyWS.OpenDatabase(strDBName)

On Error Resume Next
'Drop any existing temp tables from a leftover abort
db.Execute ("Drop Table ImportTempTable1")
db.Execute ("Drop Table ImportTempTable2")
(...whatever)

On Error GoTo Err_cmdOK_Click
'Import the data to temp tables in the current database
DoCmd.TransferDatabase acImport, "Microsoft Access", strDBName, acTable,
"Table1", "ImportTempTable1", False
DoCmd.TransferDatabase acImport, "Microsoft Access", strDBName, acTable,
"Table2", "ImportTempTable2", False
'Delete any existing data in the current db, since you are importing new data.
There may be relationships.
db.Execute ("Delete from Table2")
db.Execute ("Delete from Table1")
db.Execute ("INSERT INTO Table1 SELECT * FROM ImportTempTable1;")
db.Execute ("INSERT INTO Table2 SELECT * FROM ImportTempTable2;")

db.Execute ("Drop Table ImportTempTable1")
db.Execute ("Drop Table ImportTempTable2")

'You must have a config table to record things like client details, db
version, whatever
DoCmd.TransferDatabase acImport, "Microsoft Access", strDBName, acTable,
"Config", "ImportTempTable1", False
db.Execute ("Delete from Config")
db.Execute ("INSERT INTO Config SELECT * FROM ImportTempTable1;")
db.Execute ("Drop Table ImportT1")

DoEvents

dbs.Close
'db.Execute ("Drop Table ImportT1")
'db.Execute ("Drop Table ImportT2")
gintResult = True
DoCmd.Close

Exit_cmdOK_Click:
DoCmd.Hourglass False
Exit Sub

Err_cmdOK_Click:
MsgBox Error$, , SYSNAME
GoTo Exit_cmdOK_Click

End Sub
-----
This is approx what I do for a runtime remote scenario and is not
comprehensive. It needs a lot of test runs. If you can visit a site with full
Access, you might just as well run the one-step process Tools, Database
Utilities, Convert Database :)

(I do it this way, and test it thoroughly, because there is no prospect of my
visiting remote sites. If I don't test it thoroughly, then they are down and
I'm bankrupt :) However, I have stuffed it up and am apparently still in
business :)) )
 
D

david epsom dot com dot au

Also, you can script a dao object to compact
a database (data only) from one version to another.

(david)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top