Reporting DB property info using dbs.Containers

M

Mango-Man

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 Reports 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 Run-time error "You can't assign a value to this object" Appreciate
any help

GB
 
D

Duane Hookom

If you want to set the value of a control in a report:
1) the control must be unbound
2) the code should be contained in the On Format event of the report section.
 
M

Mango-Man

The was the part I was missing - It was in the Header and I was not using On
Format - Works great! Thanks Duane
 

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