Finding the values of an Object's Properties

S

Sarah

hello - The NorthWind db uses code like:
If CurrentDb().Properties("StartupForm") = "Startup" Then ...
in one of its modules. I have 2 newbie questions.

1) how can I determine (using VBA) the full set of CurrentDb's Properties?
(the names of the properties and their current values.)

2) This may be the same question, but will this work for any object? I need
a good way to list (again using VBA) the names and current values of any
Object's Properties?

much thanks
Sarah
 
J

Jack Leach

how can I determine (using VBA) the full set of CurrentDb's Properties

The Object Browser (F2 or View -> Object Browser) lists all properties and
methods for each object currently referenced in your project. Their current
values can be applied to variables:

thisvar = CurrentDb.Properties("StartupForm")

or you can get them from the Immediate Window (Ctrl+G or View -> Immediate
Window):

?CurrentDb.Properties("StartupForm")


but will this work for any object?

Yup. In most cases you reference the object itself, rather than it's
properties collection. Take a Form for instance... get it's Name property...

Dim strFormName As String
strFormName = Forms("ThisForm").Name

or it's Width:
?Forms("ThisForm").Width

or a Control:
Forms("ThisForm").Controls("ThisControl").ControlSource

I need
a good way to list (again using VBA) the names and current values of any
Object's Properties?

Again, the Object Browser is a great place for this information. Often
though, I will use the built-in intellisense and just scroll the list that
pops up after you hit the "dot"

For instance, the keyword "Me" references the current form object, so when
you type:

Me.

you will see a list... this is a list of all of the Form's properties,
collections and methods - i.e. - everything you can do with the form.



Note that some properties are Read Only. Some are better left untouched.

happy coding!




--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
 
S

Stuart McCall

Sarah said:
hello - The NorthWind db uses code like:
If CurrentDb().Properties("StartupForm") = "Startup" Then ...
in one of its modules. I have 2 newbie questions.

1) how can I determine (using VBA) the full set of CurrentDb's Properties?
(the names of the properties and their current values.)

2) This may be the same question, but will this work for any object? I
need
a good way to list (again using VBA) the names and current values of any
Object's Properties?

much thanks
Sarah

To find all the property names, take a look here:

http://msdn.microsoft.com/en-us/library/aa140020(office.10).aspx

also here (for all other properties) :

http://msdn2.microsoft.com/en-us/library/aa172326(office.11).aspx
 

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