KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Minimize your Form Events
PRODUCT: 4D | VERSION: | PLATFORM:
Published On: December 17, 1999

It is a good principle in 4D to ensure that your objects and forms only have the form events activated that they need.

4D's Technical Support saw a good illustration of this principle recently. A caller was confused because a very simple output layout with a Print button in the footer was generating an error after the first page was spooled. The method in the button was a single line:

print selection([...])

The default output form was the very form containing the button. The error
message the caller saw was:

This command cannot be used because a record of the table is in a form.

The problem was that the print button had its On Printing Header event turned on. So in the middle of the print job, the method was firing off again, and trying to start the print job again. No wonder 4D was confused!

Another good principle is to always check your form event. If the object
method did this:

if (form event=on clicked)
print selection([...])
end if

there would have been no problem either.