Is it possible to check, if a document is opened via link?

Hi,

as in the subject mentioned, is it possible to check, if a document is opend via a link?

My problem is the following.

In a form the property “Automatically enable Edit Mode” is set.

But under certain conditions this form may only be opened in Read Mode.

I catch this case with the following code in the Postopen Event:

If doc.ActionInAct(0) <> “0” And Source.EditMode = True Then

source.editmode = False

End

end if

If I open the document in the database, everything works fine.

If I open the document via a link from the mail database (an agent sends mails with a doclink in it), then the Queryopen (and the Postopen) event is accessed two! times.

The first cycle runs without problems (means the document is set to Read Mode), on the second cycle the document is still in Read Mode, so the code (source.editmode = false) is not executed.

But (I think because of the automatic edit mode property, but I need this) the document tries to get in Edit Mode.

Querymode change is executed.

There is the code:

If source.document.ActionInAct(0) <> “0” And Source.EditMode = False Then

Messagebox “Das Dokument befindet sich bis zum " & Strright(doc.ActionInAct(0),”§“) & " im Status ““Ruhend”” und kann somit nicht bearbeitet werden!”,64,MsgT

Continue = False

End

End If

The messagebox is executed and then, despite of the “continue=false”, the document is set to Edit Mode.

With R5 there is a different problem. The Events are executed just once, but on opening the document via a link, the “source.editmode = false” command results in an “Document command is not available” error.

Has somebody any ideas?

Greetings

Robert

Subject: RE: Is it possible to check, if a document is opened via link?

This test of ActionInAct field makes it look like you’re modifying the document every time it’s opened from a view so that you can tell it was? Bad idea. Use the Queryopendocument event to set an environment variable instead.

Rather than have the form open in edit mode by default and decide whether you have to switch it back, why not have it open in read mode by default and in the Postopen event figure out whether you need to switch to edit? The problem with switching from edit to read mode is that it’s implemented by essentially closing and reopening the document (which is probably why you’re seeing some events trigger twice). Switching from read to edit mode can be done while the document is still open.

Subject: RE: Is it possible to check, if a document is opened via link?

Hi,

thanks to your responses.

The ActionInAct field is set with a button in the form not in any open events. After the field is set, only read mode is allowed.

But I will try experimenting with an environment variable, that’s a good idea.

If nothing helps, I think I will open the form initially in read mode (again).

Actually I open the document automatically in edit mode, because the document opens nearly a second faster this way.

It is a form with many, many fields and needs about 3 seconds to open, opening the form automatically in edit mode, it needs just about 2 seconds.

Thanks for your help,

Greetings

Robert

Subject: Is it possible to check, if a document is opened via link?

what is the END doing there, it stops the execution of the code and does not let the client work through.