AccesobjectProperty and reports...huh?

M

Mark Burns

Ok, I think I grok this, but I guess I don't.

I want to access the description of reports and forms as displayed in the
database window in detail mode, if they exist.

I have a report.
I select it in the database window.
I right-click and select Properties from the pop-up menu.
I type in a description for the report and hit OK.
I see the desccription of the report in the database window.

"Ok," I think, "now the Accessobject for the report has an
AccessObjectProperty with Name="Description" and Value = <the stuff I just
typed in>...right?"

So I go to the immediate window and type:
?application.codeproject.allreports("my report name here").properties.count
answer: 0

HUH? Where the heck is the description for the dang report stored, then?

I need to grab this description WITHOUT having to open an instance of the
report...
HELP!
 
K

Ken Snell

You access reports via this syntax (example is to show the name of a report
that is named "NameOfYourReport"):

CurrentDb.Containers("Reports").Documents("NameOfYourReport").Name
 
A

Allen Browne

Just to add to Ken's answer:
CurrentDb().Containers("Reports").Documents("MyReport").Properties("Descript
ion")
generates error 3270 if nothing has been entered for the description.
 
M

Mark Burns

Allen Browne said:
Just to add to Ken's answer:
CurrentDb().Containers("Reports").Documents("MyReport").Properties("Descript
ion")
generates error 3270 if nothing has been entered for the description.

Thanks!

....just out of curiosity, is this actually documented anywhere where a
typical human might eventually be able to find it, or must one upgrade to
the Klingon (brain-installed-upsidedown-and-backwards) mind in order to
figure this seemingly obscure &$#*&$^#% stuff out?
 
K

Ken Snell

In VBE Help (must be in VBEditor), do Index search on the following:

Database;collection;

That'll get you in the ballpark!
 
M

Mark Burns

Ken Snell said:
In VBE Help (must be in VBEditor), do Index search on the following:

Database;collection;

That'll get you in the ballpark!

er... huh? I'm not concerned about collections, dude.

how does that shed any light on report document properties?
....and whether a particular item shows up thru AccessObject(s) or this
Containers("...").Documents("...") way of looking at the DB objects (and why
the heck does it show up under 1 method and not the other??)
Finding out this stuff is the kind of crud that can drive you absolutely
nuts!
 
A

Allen Browne

Mark, there are always so many ways to try to do something in Access that it
can be frustrating working out which ones work, and then which will be the
most efficient. That only comes with experience, so be patient with
yourself.

The vast majority of the information about the form and its properties can
only be gained if you open the form itself - in design view, and hidden if
you wish.
 
T

Tim Ferguson

...just out of curiosity, is this actually documented anywhere where a
typical human might eventually be able to find it,

To be honest, there is practically no reason to want to access the
description properties programatically. It is not unreasonable to assume
that people who actually need it already know enough about the Access/ DAO
model to be able to nose around the help files until they get there, or
have access to programming books/ manuals that will refer to the same.

Have you tried looking up "description" in the VBA help file? On my system,
it's the ninth entry -- although it's painfully true that recent MS help
files are unreliable and usually broken.

B Wishes


Tim F
 
Y

Yuan Shao

Hello Mark,

How is the issue going on your side? Does Allen's suggestions address your
problem? Let us know if you need further assistance on this issue.

Regards,

Michael Shao
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
M

Mark Burns

Michael (/ "Yuan"?)

Allen's information did get me going, but I still wonder why there's such
inconsistency within Access over these seemingly little things (seemingly
little until you're tripping over them and losing hours figuring out why the
$&#%$! things aren't working as the documentation suggests they should) -
and why they're sometimes so poorly documented to begin with.

- Mark
 
Y

Yuan Shao

Hellow Mark,

Currently, I am performing some further research on the cause of this
strange behavior. I will update you later. In the mean time, if you have
any other useful information, please feel free to let me know. Thanks for
your understanding.

Regards,

Michael Shao
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
M

Mark Burns

"Yuan Shao" said:
Hellow Mark,

Currently, I am performing some further research on the cause of this
strange behavior. I will update you later. In the mean time, if you have
any other useful information, please feel free to let me know. Thanks for
your understanding.

Regards,

Michael Shao
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
M

Mark Burns

"Yuan Shao" said:
Hellow Mark,

Currently, I am performing some further research on the cause of this
strange behavior. I will update you later.

Cool! - I'd appreciate that.
 
M

Mark Burns

Here's the code I came up with...FYI

Public Function GetDescription(strName As String) As String
Dim strDesc As String, bFnd As Boolean
Dim n As Variant, nn As Variant
Dim i As Integer, ii As Integer

strDesc = ""
bFnd = False
For i = 0 To CurrentDb.Containers("Reports").Documents.Count - 1
If CurrentDb.Containers("Reports").Documents(i).Name = strName Then
For ii = 0 To
CurrentDb.Containers("Reports").Documents(i).Properties.Count - 1
'Set nn = CurrentDb.Containers("Reports").Documents(i).Properties(ii)
If CurrentDb.Containers("Reports").Documents(i).Properties(ii).Name =
"Description" Then
strDesc =
CurrentDb.Containers("Reports").Documents(i).Properties(ii).Value
bFnd = True
Exit For
End If
Next
End If
Next
If Not bFnd Then
For i = 0 To CurrentDb.Containers("Forms").Documents.Count - 1
If CurrentDb.Containers("Forms").Documents(i).Name = strName Then
For ii = 0 To
CurrentDb.Containers("Forms").Documents(i).Properties.Count - 1
'Set nn =
CurrentDb.Containers("Reports").Documents(i).Properties(ii)
If CurrentDb.Containers("Forms").Documents(i).Properties(ii).Name =
"Description" Then
strDesc =
CurrentDb.Containers("Forms").Documents(i).Properties(ii).Value
bFnd = True
Exit For
End If
Next
End If
Next
End If
GetDescription = strDesc

End Function
 

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