Finding the values of an Object's Properties

  • Follow


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
0
Reply Utf 2/2/2010 11:49:01 PM

> 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) 



"Sarah" wrote:

> 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
0
Reply Utf 2/3/2010 12:06:10 AM


"Sarah" <Sarah@discussions.microsoft.com> wrote in message 
news:6153C213-009B-4BE9-8BC3-E7CF63B2200F@microsoft.com...
> 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


0
Reply Stuart 2/3/2010 12:17:56 AM

2 Replies
123 Views

(page loaded in 0.032 seconds)

Similiar Articles:
















7/18/2012 8:39:13 AM


Reply: