VBA slow accessing LookupTable

A

angus404

I am trying to display the values in a lookup table in a combo box on a form
in project VBA. I am in Project 2007.

I used this same code in 2003 and had no problems, but in 2007 it is
extremely slow.

'Find correct Lookup table
For iPGIndex = 1 To MSProject.GlobalOutlineCodes.count
If MSProject.GlobalOutlineCodes(iPGIndex).FieldID =
pcTOProcessTeamEquipmentOwner Then
Exit For
End If
Next

Set lkp = MSProject.GlobalOutlineCodes(iPGIndex).LookupTable
ReDim sPG(1, lkp.count)
For i = 1 To lkp.count
sPG(0, i) = lkp.Item(i)
sPG(1, i) = lkp.Item(i) & " - " & lkp.Item(i).Description
Next

cboMPG.ColumnCount = 2
cboMPG.ColumnWidths = "0, 100"
cboMPG.BoundColumn = 1
cboMPG.Column = sPG

There are 143 items in my lookup table, and it takes 18 seconds to fill the
combo. I systematically commented out lines of code to see what is taking
time. All of the time is spent with the 2 lines inside of the for next loop
just accessing the lookup item, lkp.Item(i). If I comment out one of the 2
lines, the load time goes down to 9 seconds.

Is there a better way to do this? Do you have any ideas why this is taking
so long?
 
R

Rod Gill

Unfortunately, LookupTables do not have a collection of LookupTableEntries.
I suspect the fastest solution would be to read the data from the Reporting
database

--

Rod Gill
Microsoft MVP for Project

Author of the only book on Project VBA, see:
http://www.projectvbabook.com
 

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