Embedded editor & View, loss of focus?

Setup:Form has a two row table.

Row 1 = embedded editor

Row 2 = embedded single category view.

Both the form with the embedded editor/view and the form used as the embedded editor are set to not refresh fields. I tried it with refresh on and there was no change in the outcome.

Embedded editor has all elements on the form set to hide when embedded excep the action bar.

The action bar has seven main actions with 7 sub-actions.

The main actions match fields created for each day of the week.

The intent is to provide the user with one or two docs they need to manage and make it look like a view with actions.

I need the docs to go into and out of edit mode since I have a subform that uses the PostOpen and QuerySave events to generate an audit trail.

Each action is basically the same:

Pass a set of pre-determined values to the INI file.

Call an @Function agent.

The agent:

Put the doc in edit mode

Reads the INI values

Uses @Setfield to set the field values

Save the doc

Exit edit mode.

If I use one of the buttons, it works great.

Most of the time, if I step through one sub action for each day of the week in a single go, everything works great.

If, however, I start to use different sub-actions in a single session, the actions work every other time.

If I

Click the doc in the embedded view

Execute a sub-action

Click the doc in the embedded view

Execute a sub-action

Everything works great.

So, it appears that, for some reason, some sequence of action clicks results in the embedded editor loosing it’s handle on the doc in the embedded view.

The subform code does not do anything to the document, it only creates new audit trail docs. I disabled the subform code and nothing changed.

Because of the way our network is set up, I can’t copy/paste the code here so below is a conceptual model of the code. Essentially, I pass in the field names I want to update and values for those fields.

There is more code, but none of it triggers a file save.

Button:

@SetEnvironment(“FieldToEdit”;“Field1”);

@SetEnvironment(“Value1”;“Something”);

@Command([RunAgent];“MyAgent”);

MyAgent:

@Command([EditDocument];“1”);

FieldToEdit := @Environment(“FieldToEdit”);

MyVal := @Environment(“Value1”);

@SetField(FieldToEdit;MyVal);

@SetEnvironment(“Value1”;“”);

@PostedCommand([FileSave]);

@PostedCommand([EditDocument];“0”);

I’ve searched here, no hits on this specific problem.

I’ve been to Chris Blatnick’s site and can’t find anything there.

I’ve tried a nuber of different things, all to no effect.

Add ‘EditSelectAll’ at the start of the agent.

Add ‘EditSelectAll’ at the end of the agent prior to exiting edit mode.

Moving all of the code into each button.

Move the ‘EditDocument’ code into the button

Create one agent to enter edit mode, one to update the data, and one to save/exit edit mode.

Killed a chicken.

I don’t understand why and embedded editor wouldn’t edit a document in an embedded view.

TIA for any help.

Doug

Subject: Getting closer

In the code, one of the things I want/need to do is test to see if a field is being changed and, if it is, ask the user for a reason.

Turns out issuing an @Prompt causes the embedded editor and embedded view to uncouple and many bad things happen - most notably, the problem of the code running every other time you try and use the action button.

If I replace the Prompt with a hard coded string, the code works fine.

If I figure out a fix, I’ll be back…

Subject: Hmmmm, or not

If I move the code out of the form actions and into buttons that sit on the form, the code seems to execute every time.

I’d prefer to use form actions since I can cascade them - any ideas?

I’ll keep working on this and let you know what else I find.

Doug

Update - no joy. It seemed to be working, but it’s not. It’s even worse with the code in form buttons.

Subject: Embedded editor/view - gotcha summary

I think I understand what went wrong and how to work around the issues. I’m going to restate what I was trying to accomplish, what wasn’t working, and how I got the code to run.

Objectives:

  1. Present the user with a ‘my stuff’ dashboard form containing a two row form, row 1 = the action bar only from an embedded editor and row 2 was a single cat view containing the user’s stuff. The effect was a ‘view of my stuff with view actions to just update specific fields’. This keeps the user from having to open the doc to update it.

  2. I must put the doc into edit mode because I use PostOpen and QuerySave code to generate an audit trail.

  3. I also must determine if the user is changing any one of a set of fields and prompt them for a reason. If no reason is entered, the code must abort.

  4. The user must be able to use any one of actions on the embedded editor in a single session. ‘Session’ means they a single display of this dashboard. If the exit the db, that ends the session.

  5. The bulk of the code must live in an agent so the embedded editor action code is as small and easy to maintain as possible.

Issues:

When to put the document into edit mode.

When to take the document out of edit mode.

When to prompt the user for a reason they changed some important field.

What worked:

Action code:

Force the doc into edit mode.

Send variable data to the INI

Execute the agent

Agent code:

Get the ini values

Determine if one of the ‘important’ fields is being updated.

If so, ask the user for a reason.

@If(Reason = “”;

@Do(

@PostedCommand([EditDocument;“0”);

@PostedCommand([FileCloseWindow]);

@PostedCommand([FileCloseWindow]);

@PostedCommand([FileOpenDatabase];server;database;“”;“”;“”;“”);

@Return(@Prompt([ok];“Error”;"you must enter a reason)));

@Success);

Process the rest of the code if allowed.

Save the doc using

@PostedCommand([FileSave]);

@PostedCommand([EditDocument;“0”);

@PostedCommand([FileCloseWindow]);

@PostedCommand([FileCloseWindow]);

@PostedCommand([FileOpenDatabase];server;database;“”;“”;“”;“”);


What did NOT work:

If, in the ‘test for a reason’ code I use something like:

@Do(

@Command([EditDocument];“0”);

@Return(@Prompt([ok];“Error”;“enter the data”));

The code seems to execute but it leaves the doc in edit mode causing all kinds of errors related to ‘you are going to create a rep/save doc’ since I use the same code in a different action buttons.

If I do something like:

@Do(

@PostedCommand([EditDocument];“0”);

@Return(@Prompt([ok];“Error”;“enter the data”));

The code works ONLY every other time. The action has focus on the doc, then it doesn’t, then it does.

The only way the code seems to execute consistently as I want is to:

Use @Posted commands

Terminate the user’s ‘session’ by closing the db and re-opening it.

I could ask the user to click the document in the embedded view, but since I can’t guarantee that will happen and the results if they don’t will be VERY confusing to them, I opted to just slam the db shut and re-open it.

This is a bit of a ramble but I hope it helps somebody somewhere along the way (or somebody enlightens me on how to get this thing to work the way I want).

Doug

More info if you’re a true glutton for punishment.

Db uses a two frame design - left frame is an outline, right frame defaults to the 'my stuff ’ dashboard form.

There are actually a number of dashboards with different sorts and groupings of data subsets. Only two use the embedded editor/view design.

I’ll be modifying the frame design to use an ini variable to set the right frame content and in each dashboard I’ll set the variable so when the agent closes/re-opens the db, it re-opens in the same place the user started.

If anybody has other questions or wants to see the whole ugly code mess, let me know and I’ll post here.

The use of the double [FileCloseWindow] commands is because of the framed design - it takes two to actually close the db.