does the task object have a fields collection?

M

Mark VII

Hello --

I'm doing some development to pull Project data into an Access database to
do some rather elaborate reports. Is there a fields collection for a task
object, analagous to the fields collection for a tabledef object under DAO?

What I'm trying to do here is be able to write an assignment statement where
the field reference is variable instead of hard coded. I'm trying to avoid
having to write an assignment statement for every Project field of interest.
Here's some pseudocode for what I'm trying to do:

for each task in ActiveProject.tasks
for each field in Task object
'* look up access field name in a cross reference table
TargetTable.Fields(<field name from lookup>) = Task.Fields(<field
name
from task object>)
next field
next task

Looping through tasks is not an issue for me, and I've got the field name
cross reference figured out. The big unknown is the assignment statement.

TIA...

Mark
 
J

John

Mark VII said:
Hello --

I'm doing some development to pull Project data into an Access database to
do some rather elaborate reports. Is there a fields collection for a task
object, analagous to the fields collection for a tabledef object under DAO?

What I'm trying to do here is be able to write an assignment statement where
the field reference is variable instead of hard coded. I'm trying to avoid
having to write an assignment statement for every Project field of interest.
Here's some pseudocode for what I'm trying to do:

for each task in ActiveProject.tasks
for each field in Task object
'* look up access field name in a cross reference table
TargetTable.Fields(<field name from lookup>) = Task.Fields(<field
name
from task object>)
next field
next task

Looping through tasks is not an issue for me, and I've got the field name
cross reference figured out. The big unknown is the assignment statement.

TIA...

Mark

Mark,
Take a look at the GetField Method. You can set up a variable to hold
the FieldID argument.

Hope this helps.
John
Project MVP
 
M

Mark VII

Take a look at the GetField Method. You can set up a variable to hold
the FieldID argument.

Hi John -- Thanks for that suggestion. Is there an easy way to develop a
list of the various constants for the field names and the associated "under
the covers" values? I'd like to avoid doing a brute force manual trip
through the object browser.

Thanks,
Mark
 
J

John

Take a look at the GetField Method. You can set up a variable to hold
the FieldID argument.

Hi John -- Thanks for that suggestion. Is there an easy way to develop a
list of the various constants for the field names and the associated "under
the covers" values? I'd like to avoid doing a brute force manual trip
through the object browser.

Thanks,
Mark[/QUOTE]

Mark,
I don't know of an easy way but there can't be that many fields that
you'll have to deal with. Looking them up in the object browser need not
be a big deal. For example, if you want to know all the constants
associated with the assignment object, first search for "assignment".
Then in the Classes list find PjAssignmentField. Selecting that will
show all assignment constants.

Hope this helps.
John
Project MVP
 
R

Rod Gill

One way to approach this is to get your macro to open the project then save
it to another Access database. You will then have all fields in Access and
can create Views to select which fields are needed so you can copy all
fields in the View.

Otherwise in Project you can create a Table with all the fields you want
then there is a TableFields collection for each Table. (I think this may
only be available from project 2002 onwards from memory).

--

Rod Gill
Project MVP

Project VBA Book, for details visit:
http://www.projectvbabook.com

NEW!! Web based VBA training course delivered by me. For details visit:
http://projectservertraining.com/learning/index.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