Load field values in PostOpen event

I have some code in the PostOpen event of a summary form that looks at a view for documents. I get all the documents in the view that are related to the summary form and load their values into different fields in the summary form. The code in the PostOpen even looks like this:

Set doc = Source.Document

Set view = db.GetView(“Search”)

Call view.Refresh

Set vc = view.GetAllEntriesByKey(keyvalue)

Set firstItem = doc.GetFirstItem( “firstField” )

Set secondItem = doc.GetFirstItem( “secondField” )

firstItem.Values = “”

secondItem.Values = “”

Call doc.Save(False, False)

I always reset the values of the firstItem and secondItem fields to blanks before doing anything else. But, when I process the rest of the code that assigns values to these fields, I always get old values instead of the values from the documents in the view. I have to close the document and reopen it to see the updated information. What am I missing?

Subject: Load field values in PostOpen event

It depends on how you are changing the values - in the uidoc or in the doc?

If you use doc.ReplaceItemValue(), you shouldn’t have to clear the old values.

You might need to use doc.Reload as well.

Can you put your code in QueryOpen instead of PostOpen?

Subject: RE: Load field values in PostOpen event

I’m using the doc to make the changes to the fields. I also use uidoc.Reload at the end of my code and that doesn’t make a difference. Maybe I’ll try to queryopen to see if that makes a difference. Thanks!

Subject: THANKS! QueryOpen works great!