1

I want to set flag type enterprise custom field at the task level to True/False Or Yes/No. May I know the syntax for the same in VBA.

The MSDN says:

projectField = FieldNameToFieldConstant("TestEntProjText", pjProject)

ActiveProject.ProjectSummaryTask.SetField FieldID:=projectField, Value:="This is a new value." 

where Value is a string. But in my case I want it to be a boolean value.

2 Answers 2

0

The SetField method always takes a string value but can be used to set any field. Use "Yes" and "No" to set Boolean values.

The related method GetField returns a field value as it is displayed in the table view and thus always returns a string.

Sign up to request clarification or add additional context in comments.

Comments

0

Sub setEnterpriseFlag()

Dim myTask As Task
Set myTask = ActiveProject.Tasks.Item(1)

Debug.Print myTask.GetField(pjTaskEnterpriseFlag1)
Debug.Print myTask.GetField(pjTaskEnterpriseFlag2)

myTask.SetField pjTaskEnterpriseFlag1, boolToStr_forSetField(True)
myTask.SetField pjTaskEnterpriseFlag2, boolToStr_forSetField(False)

Debug.Print myTask.GetField(pjTaskEnterpriseFlag1)
Debug.Print myTask.GetField(pjTaskEnterpriseFlag2)

End Sub

'Unfortunately task.SetField and task.GetField deal only with strings. An easy 'way to manage this would be to use a simple wrapper function. Function boolToStr_forSetField(boolVal As Boolean) As String If boolVal Then boolToStr_forSetField = "Yes" Else boolToStr_forSetField = "No" End If End Function

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.