Notes Error - Cannot locate field

I get the error - Notes error - Cannot locate field when I open a form and click on anything the first time. Then it goes away. I think it’s in the postopen code:

Sub Postopen(Source As Notesuidocument)

Dim uidoc As NotesUIDocument

Dim workspace As New NotesUIWorkspace

Set uidoc = workspace.CurrentDocument

If uidoc.IsNewDoc Then

   If (uidoc.FieldGetText("CPCreateSRFlag") <> "Y") Then

       Call source.FieldClear("Phone")

       Call source.FieldClear("Bldg")

       Call source.FieldClear("Office")

       Call source.FieldClear("Customer_Name")

	Else

Call source.FieldClear("CPCreateSRFlag")

	End If 

End If  

End Sub

Can anyone help me? Thanks, Diane

Subject: Notes Error - Cannot locate field

  1. try to remove this code to see if the error will disappear.2. Such error may happen because the CPCreateSRFlag field doesn’t exist.

  2. If the document is created using some other inherited fields ( to populate the fields participating in the postopen) then the code may makes sense. Otherwise for a new docuemnt all the fields are still empty, so the code doesn’t make sense.

Subject: Notes Error - Cannot locate field

Diane

Sorry, I created a form with just the fields you have in your code, and put your code in the PostOpen of the form. I did not receive any errors (running 7.0.2 client).

On a side note, you already have access to the current uidoc (Source), so you shouldn’t need to create your own uidoc (your code uses both the Source and uidoc you’ve created) unless I’m missing something.

Subject: Notes Error - Cannot locate field

Turn the debugger on and it will give you the line where the error occurs.

A possible cause is the line

Call source.FieldClear(“CPCreateSRFlag”)

as an existing document needs to be in edit mode for this to work. Unless you have the property automatically open in edit mode enabled this will cause an error whenever you open an existing document.

Subject: Notes Error - Cannot locate field

Check your script, whether there is any typo mismatch of field names.