Exception when setting the form field.

Q: I create a form field (Text Field) using Adobe LiveCycle Designer
7.0". In the program, I set that form field to a value in my variable
buf as:

itr.Current().GetValue().SetStr(buf);

, it creates an exception: "Object reference not set to an instance of
an object.".
----

A:

It is possible that the PDF form field doesn't have any value
associated with the field.

To go around this problem, use the following code when modifying the
form field:

// In C#
Field field = itr.Current();
field.SetValue(Obj.CreateString(buf));

// In C++
Field field = *itr;
field.SetValue(new Str(buf));