Skip to content

CustomFieldValueList

Hannes de BruyneMember for 21 years 2 months
Created
3
4
0
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

3 replies

Oldest first
  1. 0
    D C ·
    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
  2. 0
    Hannes de Bruyne ·
    Thank you DC

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

    Hannes
  3. 0
    D C ·
    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

Log in or join to reply

ProjectControls.com is free to join. Members can post questions, reply, vote and follow discussions.

Existing members: your original username and password still work. Forgot password?