Create SummaryInfo & UserDefined Properties on New MDB?

V

victorcamp

I'm creating a new MDB on-the-fly via VBA code. Works great. Now I want to
add info that's found in the Database Properties window. Not so great.
Various properties in that window are found in:
CurrentDb.Containers![Databases].Documents![SummaryInfo]
and
CurrentDb.Containers![Databases].Documents![UserDefined]

However, a new MDB comes with only 1 Document in that collection: MSysDb,
and there's no Add method for adding Documents (I tried). It appears they're
only created the first time you add something to the Database Properties
window manually. Once they are there, I have no problem creating new
properties via VBA that then show up in that window.

How can I get those 2 documents created via VBA?
 
P

Paul Shapiro

You can try creating the properties and adding them to the CurrentDB object:
'Create Property object, setting its Name, Type, and Value
properties.
Set MyProperty = CurrentDB.CreateProperty(strPropertyName,
intPropertyType, varPropertyValue)
'See if we can append the new property
CurrentDB.Properties.Append MyProperty
Some properties cannot be added this way, but I think it should work for the
ones you want.
 
V

victorcamp

I can create properties to the CurrentDb, for example "AppTitle", but the
properties that show up in the Database Properties window are all in
specific Documents, and it's those Documents (SummaryInfo and UserDefined)
that I can't create. They only show up in the Database Properties window if
they're found in those specific Documents.

I have been experimenting with a workaround. An Autoexec Macro transferred
to the new database can enter some data via SendKeys, then code could do the
rest. For example:

SendKeys
My MDB^{TAB}^{TAB}^{TAB}{TAB}AppVersion{TAB}{TAB}1.1.01%A{ENTER}
Yes
RunCommand
DatabaseProperties

This does add one item each to the two Documents, thus creating them. Code
could then do the rest. I still have more experimenting to do so that it
will only fire once. That subsequent code also requires a Reference that
will have to be added during creating of the MDB, something I'm still
working on.


Paul Shapiro said:
You can try creating the properties and adding them to the CurrentDB
object:
'Create Property object, setting its Name, Type, and Value
properties.
Set MyProperty = CurrentDB.CreateProperty(strPropertyName,
intPropertyType, varPropertyValue)
'See if we can append the new property
CurrentDB.Properties.Append MyProperty
Some properties cannot be added this way, but I think it should work for
the ones you want.

victorcamp said:
I'm creating a new MDB on-the-fly via VBA code. Works great. Now I want
to add info that's found in the Database Properties window. Not so great.
Various properties in that window are found in:
CurrentDb.Containers![Databases].Documents![SummaryInfo]
and
CurrentDb.Containers![Databases].Documents![UserDefined]

However, a new MDB comes with only 1 Document in that collection: MSysDb,
and there's no Add method for adding Documents (I tried). It appears
they're only created the first time you add something to the Database
Properties window manually. Once they are there, I have no problem
creating new properties via VBA that then show up in that window.

How can I get those 2 documents created via VBA?
 

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