Create an Access 2000 format database using DAO?

  • Thread starter Cory J. Laidlaw, Beyond01.com
  • Start date
C

Cory J. Laidlaw, Beyond01.com

Hi,

I've tried the following line of code:

Set tdb = DBEngine.Workspaces(0).CreateDatabase(TargetPath, dbLangGeneral,
dbVersion30)

it creates an access 97 version of the database. This line of code:

Set tdb = DBEngine.Workspaces(0).CreateDatabase(TargetPath, dbLangGeneral,
dbVersion40)

Creates an access 2002-2003 version.

Does anyone know how to create an Access 2000 Version?
Many Thanks!!

Cory
 
Joined
Dec 17, 2007
Messages
57
Reaction score
0
Cory J. Laidlaw said:
Hi,

I've tried the following line of code:

Set tdb = DBEngine.Workspaces(0).CreateDatabase(TargetPath, dbLangGeneral,
dbVersion30)

it creates an access 97 version of the database. This line of code:

Set tdb = DBEngine.Workspaces(0).CreateDatabase(TargetPath, dbLangGeneral,
dbVersion40)

Creates an access 2002-2003 version.

Does anyone know how to create an Access 2000 Version?
Many Thanks!!

Cory

Cory,
I don't know the answer to your question, but I did find this reference link that may lead you to more info.

http://www.groupsrv.com/computers/about12373.html


Here's another link on same topic:

http://www.microsoft.com/office/com...us-office-access〈=en&cr=US&sloc=en-us&m=1&p=1
 
Last edited:
R

Robert Morley

If I recall correctly, at the low level, Access 2000 and Access 2002/2003
are actually the same database format. So if you create a Version40
database through code, the identifiers as to whether it's 2000 or 2002/3
will only be added when you open that database up through the GUI and
they're added by Access itself (as opposed to DAO). So at that point, as
Alex indicated, it's controlled by the setting in your preferences.

I'm a little rusty, so I might be wrong, but I'm pretty sure that's how it
works.


Rob
 
C

Cory J. Laidlaw, Beyond01.com

Hi Alex,

Thanks for your help!

Sadly, it doesn't work. It appears that the createdatabase() method does not
check the options setting.

Here is my code:

Dim tdb as dao.database

' create new microsoft access database file in Access 2000 format.
PrevSetting = GetOption("Default File Format")
SetOption ("Default File Format"), 9

Set tdb = DBEngine.Workspaces(0).CreateDatabase(TargetPath, dbLangGeneral)
SetOption ("Default File Format"), PrevSetting

this code creates a 2002-2003 database format. Even if I manually go back
and set the option by using Tools|options|advaned|default file format and set
it to 2000, this code still creates it in the later format.

the 2000 format was wildly popular. I feel silly how hard it is to do create
a database in 2000 format.

Any other suggestions would be greatly appreciated. Thanks!!

Cory
 
C

Cory J. Laidlaw, Beyond01.com

Hi Robert,

Thanks for your feedback. I am a bit confused.

If they are the same format, why in access 2003 is there a tool(database
utilities( to convert them to 2000 format and when using a 2000 format
database, the tool converts a database up to 2002-03?

Your saying this is just symantecs of the current access application?

Thank you. I appreciate your feedback! :)

Cory
 
S

Stuart McCall

"Cory J. Laidlaw, Beyond01.com"
Hi Alex,

Thanks for your help!

Sadly, it doesn't work. It appears that the createdatabase() method does
not
check the options setting.

Here is my code:

Dim tdb as dao.database

' create new microsoft access database file in Access 2000 format.
PrevSetting = GetOption("Default File Format")
SetOption ("Default File Format"), 9

Set tdb = DBEngine.Workspaces(0).CreateDatabase(TargetPath, dbLangGeneral)
SetOption ("Default File Format"), PrevSetting

this code creates a 2002-2003 database format. Even if I manually go back
and set the option by using Tools|options|advaned|default file format and
set
it to 2000, this code still creates it in the later format.

the 2000 format was wildly popular. I feel silly how hard it is to do
create
a database in 2000 format.

Any other suggestions would be greatly appreciated. Thanks!!

Cory

PMFJI. Why not keep a 'master' empty A2000 mdb file and when you need a new
one, copy that, then open it in Access version whatever (>= A2000 of course)
....
 
R

Robert Morley

The gist of it is that only the Forms, Reports, Macros and Modules are
stored in a different format for each. The Tables and Queries are stored in
a generic format that's the same for both. Since DAO only knows about
Tables and Queries, it can't really create a database that's one or the
other; it creates a v4.0 database which is later modified by Access itself
to be whichever format it wants. This also explains the behaviour you saw
with your code in Alex's sub-thread; there's no version to the database
until you actually open it.

What the conversion utility does is to convert all the other objects from
2000 to 2002/2003. If you change your options to view System Objects,
you'll see an MSysAccessObjects in 2000 vs. and MSysAccessStorage in 2002/3.
This is where all the Forms, Reports, etc. are stored.

Oh and it appears that Norton has corrupted you. It's not "symantecs", it's
"semantics". ;)

Anyway, if it's important for you to select the database format before first
GUI access, try the following code instead. Note that if you need "tdb" to
point to the database once it's done, you'll have to re-open the database
through DAO afterwards. Access can't create the necessary table while DAO
has a lock on it (at least I don't think so...you can try opening it in
shared mode and see if that works out).

Public Sub MyCreateDatabase(ByVal TargetPath As String)
Dim tdb As DAO.database
Dim accapp As Access.Application
Dim PrevSetting As Variant

' create new microsoft access database file in Access 2000 format.
On Error Resume Next
Kill TargetPath
On Error GoTo 0

Set tdb = DBEngine.Workspaces(0).CreateDatabase(TargetPath, dbLangGeneral)
tdb.Close
Set tdb = Nothing

Set accapp = New Access.Application
PrevSetting = accapp.GetOption("Default File Format")
accapp.SetOption "Default File Format", 9
accapp.OpenCurrentDatabase TargetPath
accapp.CloseCurrentDatabase
accapp.SetOption "Default File Format", PrevSetting
Set accapp = Nothing

End Sub



Rob
 
C

Cory J. Laidlaw, Beyond01.com

Hi Rob,

This did the trick! Thanks much for the updated code snippet.

You da man!

Cory
 

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