Writing to and Reading from DB Properties window

M

Mango-Man

I am looking for a way (VBA or Macro) to write a value entered into an
unbound field on a form to the DB properties screen - File>Database
Properties>Summary>Category and also to the Custom tab to the Group which is
also a text value.

How do I reference these values later if I want to use them on a report or a
form.

I have looked at the "Set Properties of Data Access Objects in Visual Basic"
in access help but the example is a little vague. I see there is
SummaryInfo.Category but for UserDefined it states the Summary tab as opposed
to the Custom tab.

gb
 
M

Mango-Man

Okay - Update. I got everything figured out with the following

On the data entry form I have my unbound field with an On Lost Focus Event
Procedure that does the following

Private Sub Category_Info_LostFocus()
Dim dbs As DAO.Database
Set dbs = CurrentDb
'set the value of the Catgory field in Properties

dbs.Containers("Databases").Documents("SummaryInfo").Properties("Category") =
Me!CategoryName
'retrieve it to check that it was set or updated
Me!GetVal =
dbs.Containers("Databases").Documents("SummaryInfo").Properties("Category")
End Sub

Works great and on Forms I can use an On Open Event Procedure to retrieve
the value and stuff it into an unbound field CategoryName-

Private Sub Form_Open(Cancel As Integer)
Dim dbs As DAO.Database
Set dbs = CurrentDb
Me!CategoryName =
dbs.Containers("Databases").Documents("SummaryInfo").Properties("Category")
End Sub

MY PROBLEM
On Forms this does not work. I again have an unbound field named
CategoryName but I am missing something in my VBA to set the value. Error I
get is Runt-time error "You can't assign a value to this object"
 
V

Vincent Verheul

Maybe you should try this in the Form_Load event. Look at the help on
"open":

When you first open a form, the following events occur in this order:
Open ? Load ? Resize ? Activate ? Current

During the "open" event no record is yet leaded and possibly you cannot
access the unbound control either.
 
M

Mango-Man

Found the problem - Control was in the Header of the Report and needed to
select the event On_Format. Works perfectly now. Thx
 

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