Discussion:
Qs on DAO 3.6
(too old to reply)
Ivar
2012-03-27 13:38:02 UTC
Permalink
Hi All.

My App (VB6) Uses reference to DAO 3.6
If Database does not exist it creates it
mdb file only has tables, fields and relationships.

When DAO is creating database can any of the following be done

Add some kind of tag to the file that can be read via DAO that can store the
version of the exe that created it. don't want to add another table and
field just to store a little string.

When a table is opened with Access in design mode there is a description
column for each field, Can DAO write to this field when it's creating the
table and fields ? Something like 'Must Be 4 Characters Long'

when creating a field of type dbBoolean, How to display the check box in
that field if table is opened in data view. All I can get is -1 or zero?

How (When using DAO to create Database) Can I get Access to display a msgbox
if mdb file is opened using Access

Any Adivce or ideas?

Thanks

Ivar
David Youngblood
2012-03-27 15:11:16 UTC
Permalink
Post by Ivar
My App (VB6) Uses reference to DAO 3.6
If Database does not exist it creates it
mdb file only has tables, fields and relationships.
When DAO is creating database can any of the following be done
Add some kind of tag to the file that can be read via DAO that can store
the version of the exe that created it. don't want to add another table
and field just to store a little string.
When a table is opened with Access in design mode there is a description
column for each field, Can DAO write to this field when it's creating the
table and fields ? Something like 'Must Be 4 Characters Long'
when creating a field of type dbBoolean, How to display the check box in
that field if table is opened in data view. All I can get is -1 or zero?
How (When using DAO to create Database) Can I get Access to display a
msgbox if mdb file is opened using Access
Any Adivce or ideas?
I've never used/tried it, but you might look at the CreateProperty method
for your first two questions.

David
Ivar
2012-03-27 18:14:31 UTC
Permalink
Post by Ivar
Add some kind of tag to the file that can be read via DAO that can store
the version of the exe that created it. don't want to add another table
and field just to store a little string.
I've never used/tried it, but you might look at the CreateProperty method
for your first two questions.

Yep! Good answer to Q1. Had a test, all works well
Thank you David.
ralph
2012-03-27 16:06:53 UTC
Permalink
On Tue, 27 Mar 2012 14:38:02 +0100, "Ivar"
Post by Ivar
Hi All.
My App (VB6) Uses reference to DAO 3.6
If Database does not exist it creates it
mdb file only has tables, fields and relationships.
When DAO is creating database can any of the following be done
Add some kind of tag to the file that can be read via DAO that can store the
version of the exe that created it. don't want to add another table and
field just to store a little string.
Why not? That would seem to be the easiest solution. Especially since
these types of requirements always seem to expand. Today just the
executable, later additional version info, the date, change audits,
etc. <g>

However you might investigate the SummaryInfo and UserDefined property
collections.

This goes along with the next question ...
Post by Ivar
When a table is opened with Access in design mode there is a description
column for each field, Can DAO write to this field when it's creating the
table and fields ? Something like 'Must Be 4 Characters Long'
That is part of the Field Properties. Just set a new value.

Appears simple enough but there are subtle difficulties when dealing
with "Access-defined" and "DAO-defined" properties. This article will
help:

"Setting Access Properties From VB"
http://visualbasic.about.com/od/usevb6/l/aa101602a.htm
Post by Ivar
when creating a field of type dbBoolean, How to display the check box in
that field if table is opened in data view. All I can get is -1 or zero?
If you are talking about the "data view" addon that comes with VB6, it
is pretty much just what it is - a simple 'n quick viewer, and what
you see is what you get.

The source code is available for it (or at least it used to be), but
if you need something more elaborate it is simple enough to build your
own viewer/s using the Database Project Wizards.
Post by Ivar
How (When using DAO to create Database) Can I get Access to display a msgbox
if mdb file is opened using Access
You lost me there. If a "mdb file" is opened in MSAccess then I would
imagine it is known it is opened in MS Access? <g>

I'm guessing that what you want to do is if your VB6 application
currently has the file open you want a message box to appear when a
user opens it using MS Access. Considering it is just a shareable file
and the lengths Windows goes to allow clients to transparently share
files, and that MS Access doesn't normally force any special startup
code, I don't believe this would be a trivial exercise.

You might experiment with exclusive locks or access, and wrapping the
mdb with a MSAccess Project. But I really don't know. Provide more
details and I'm sure someone will be along shortly with a solution.

-ralph
Ivar
2012-03-27 22:27:06 UTC
Permalink
Post by Ivar
when creating a field of type dbBoolean, How to display the check box in
that field if table is opened in data view. All I can get is -1 or zero?
If you are talking about the "data view" addon that comes with VB6, it
<is pretty much just what it is - a simple 'n quick viewer, and what
<you see is what you get.

Nope, The Table Datasheet view in Access, No biggie, just a bit annoying
Post by Ivar
How (When using DAO to create Database) Can I get Access to display a msgbox
if mdb file is opened using Access
You lost me there. If a "mdb file" is opened in MSAccess then I would
imagine it is known it is opened in MS Access? <g>
I'm guessing that what you want to do is if your VB6 application
currently has the file open you want a message box to appear when a
user opens it using MS Access.
Nope, The VB6 app uses only disconnected recordsets, so not connected to mdb
file.
If someone opens the mdb file using Access then Access shows a msgbox saying
something like "it's your database, break it if you want to"
Easy to do using Access, Clueless if it's even possible using DAO when
creating the mdb file


Thank you very much for taking the time to reply

Anyone Else got ideas?

Ivar
ralph
2012-03-28 03:08:06 UTC
Permalink
On Tue, 27 Mar 2012 23:27:06 +0100, "Ivar"
Post by Ivar
Post by ralph
I'm guessing that what you want to do is if your VB6 application
currently has the file open you want a message box to appear when a
user opens it using MS Access.
Nope, The VB6 app uses only disconnected recordsets, so not connected to mdb
file.
Curious. How are you doing that with DAO?

-ralph
Helmut_Meukel
2012-03-28 15:58:48 UTC
Permalink
Post by Ivar
Post by ralph
I'm guessing that what you want to do is if your VB6 application
currently has the file open you want a message box to appear when a
user opens it using MS Access.
Nope, The VB6 app uses only disconnected recordsets, so not connected to mdb
file.
That's impossible with DAO.
If you really are using disconnected recordsets, then you are using ADO.
Post by Ivar
If someone opens the mdb file using Access then Access shows a msgbox saying
something like "it's your database, break it if you want to"
Easy to do using Access, Clueless if it's even possible using DAO when
creating the mdb file.
Which Access version?
This sounds like the Messagebox you get in Access, if you open an older
version of a database file. Access asks to upgrade to the current
version, but warns it will render it unusable with older versions of
Access (or DAO).
I have some db files creauted with Access 97, but the customer uses
mostly Access 2000. My programs are using DAO 3.6, so an upgrade with
Access 2000 would be no problem, but he has an older PC with only
Access 97. I warned him he must install Access 2000 on this PC if one
user allows his Access to upgrade the db file.

I never tested it with higher versions of Access, but I guess it may
even make it unusable with VB6/DAO3.6.

Helmut.
ralph
2012-03-28 18:24:00 UTC
Permalink
On Wed, 28 Mar 2012 17:58:48 +0200, Helmut_Meukel
Post by Helmut_Meukel
Post by Ivar
Post by ralph
I'm guessing that what you want to do is if your VB6 application
currently has the file open you want a message box to appear when a
user opens it using MS Access.
Nope, The VB6 app uses only disconnected recordsets, so not connected to mdb
file.
That's impossible with DAO.
If you really are using disconnected recordsets, then you are using ADO.
Post by Ivar
If someone opens the mdb file using Access then Access shows a msgbox saying
something like "it's your database, break it if you want to"
Easy to do using Access, Clueless if it's even possible using DAO when
creating the mdb file.
Which Access version?
This sounds like the Messagebox you get in Access, if you open an older
version of a database file. Access asks to upgrade to the current
version, but warns it will render it unusable with older versions of
Access (or DAO).
I have some db files creauted with Access 97, but the customer uses
mostly Access 2000. My programs are using DAO 3.6, so an upgrade with
Access 2000 would be no problem, but he has an older PC with only
Access 97. I warned him he must install Access 2000 on this PC if one
user allows his Access to upgrade the db file.
I never tested it with higher versions of Access, but I guess it may
even make it unusable with VB6/DAO3.6.
I too suspect the OP is using ADO in his VB6 App as the primary data
access library and is only using DAO for its DDL capabilities.

What he is apparently attempting to find is an Access-defined property
which will invoke a custom message whenever the database is opened. I
dont' know of any method outside of wrapping the mdb in an Access
Project - but then I'm certainly no MS Access expert. Sounds like a
useful feature however. I'd be interested too.

You are correct in warning your customer about possible problems with
MS Access clients and forward-compatiblity, but this will have less
impact on DAO 3.6. DAO 3.6 can create, read, and write all Jet formats
from Jet 1.0 to Jet 4.0 through the facilities of translator dlls.

-ralph
Clive Lumb
2012-03-29 07:29:32 UTC
Permalink
Post by ralph
On Wed, 28 Mar 2012 17:58:48 +0200, Helmut_Meukel
What he is apparently attempting to find is an Access-defined property
which will invoke a custom message whenever the database is opened. I
dont' know of any method outside of wrapping the mdb in an Access
Project - but then I'm certainly no MS Access expert. Sounds like a
useful feature however. I'd be interested too.
-ralph
Perhaps it would be possible to write/define the Access AutoExec macro
programatically in the .mdb?
(Or start from an otherwise empty template .mdb that has the AutoExec
warning in it?)

Wolfgang Enzinger
2012-03-28 10:04:27 UTC
Permalink
Post by Ivar
when creating a field of type dbBoolean, How to display the check box in
that field if table is opened in data view. All I can get is -1 or zero?
Set the "DisplayControl" Property of your Boolean field to an integer value
of 106:

Dim p As DAO.Property, f As DAO.Field
Set f = db.TableDefs("table1").Fields("yn")
Set p = f.CreateProperty("DisplayControl", dbInteger, 106)
f.Properties.Append p

HTH,
Wolfgang
Loading...