Guild of Project Controls: Compendium | Roles | Assessment | Certifications | Membership

Tips on using this forum..

(1) Explain your problem, don't simply post "This isn't working". What were you doing when you faced the problem? What have you tried to resolve - did you look for a solution using "Search" ? Has it happened just once or several times?

(2) It's also good to get feedback when a solution is found, return to the original post to explain how it was resolved so that more people can also use the results.

CustomFieldValueList

3 replies [Last post]
Hannes de Bruyne
User offline. Last seen 1 year 44 weeks ago. Offline
Joined: 25 Jul 2005
Posts: 154
Groups: None
Is there an expert, who can help me?
I trie to read a customfield-valuelist. But I cannot count the number of items in this list (n in this example). Or is there a method, that does not give an error if n is higher than the actual number?
If I delete or add an item, I notice the whole list is recreated.

Example:
If (CustomFieldGetName(pjCustomTaskText2)) <> "" Then
Cells(2, 1) = "Text2"
Cells(2, 2) = (CustomFieldGetName(pjCustomTaskText2))
For i = 1 To n
MsgBox (CustomFieldValueListGetItem(pjCustomTaskText2, pjValueListValue, i))
MsgBox (CustomFieldValueListGetItem(pjCustomTaskText2, pjValueListDescription, i))
Next i
End If

Regards
Hannes de Bruyne

Replies

D C
User offline. Last seen 16 years 51 weeks ago. Offline
Joined: 11 Dec 2006
Posts: 5
Groups: None
Only Enterprise Global have the permission to add or delete Custom Fields. When you write code to edit CustomeField at the Enterprise Global level and running it with Enterprise Global checked-in it will show a runtime error because it does NOT have permission to add or delete if it is not Enterprise Global.

How can I solve this problem? I am writing code at the Enterprise Global using Custom Fields as setting attributes to load into a form and when click "OK" it will save it back to the appropriate Custom Fields.

Any help or comments is greatly appreciated.

Thanks,

DC
Hannes de Bruyne
User offline. Last seen 1 year 44 weeks ago. Offline
Joined: 25 Jul 2005
Posts: 154
Groups: None
Thank you DC

I used a similar solution. But stil I don’t like that Microsoft uses lists without count or index -properties

Hannes
D C
User offline. Last seen 16 years 51 weeks ago. Offline
Joined: 11 Dec 2006
Posts: 5
Groups: None
Error Handling ... If you have a better suggestion please let me know. After researching the web here is a solution to this problem.

Private Sub Sub_Name()
On Error GoTo ErrHandler:

Dim i As Integer

Do
MsgBox (CustomFieldValueListGetItem(pjCustomTaskText2, pjValueListValue, i))
MsgBox (CustomFieldValueListGetItem(pjCustomTaskText2, pjValueListDescription, i))
i = i + 1
Loop

NextLable:
’You next line of code

Exit Sub

ErrHandler:
Select Case Err.Number
Case "The Error Number you are getting"
’ do something if you want
Err.Clear ’it is important to clear your error every time
Resume NextLable:
End Select
End Sub