The following method overrides the form’s open( ) method. It checks the user’s current access level and hides a button to display the administration form if the access level isn’t high enough. An overriding method is used instead of the onOpen event because onOpen fires after the form has already opened on-screen, which means that the administration button might appear briefly before it vanishes.

function open( )

   local nAccess 

   nAccess = form.rowset.parent.session.access( ) 

   if nAccess == 0 or nAccess > 4 

      form.adminButton.visible = false 

   endif 

return super::open( ) 

The session is referenced via the form’s primary rowset. The rowset’s parent is the query object, which is assigned to a session. The access level is stored in a variable for convenience because it needs to be checked twice: first to make sure security is enabled, and second to check the access level itself.