Normal Topic To activate code in Commandbutton without clicking (Read 586 times)
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
To activate code in Commandbutton without clicking
Mar 16th, 2008 at 3:01am
Print Post Print Post  
I am looking for simple way to activate OnEntryEvent code in commandbutton without clicking the button. ThrowFocus () would not work. RunEntryOnEvent( ) run amok without RemoveRunEntryOnEvent ( ) and has to establish conditional, so it does go on repeating. This worked but it is a bit more complicated. FormRunProgram( ), does it work on the same form? I am sure there must be a simpler way. I believe I had accomplished this in a lot simpler way before but cannot seem to recollect it. Please help.
  
Back to top
 
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: To activate code in Commandbutton without clic
Reply #1 - Mar 16th, 2008 at 3:10am
Print Post Print Post  
Make the code in OnEntryevent into a SubRoutine and put it into Global Code.

Now the code in OnEntry can be deleted and can call the SubRoutine instead.  That will take care of normal OnEntry activities.

But now you can also call that routine from any other element, from conditional values in an element, a dirrrerent command button, when leaving any element or form, or on any other trigger points that you desire.
  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: To activate code in Commandbutton without clic
Reply #2 - Mar 16th, 2008 at 3:11am
Print Post Print Post  
Write a subroutine in the global code area. Call it from the button's on entry event and from any other bit of code you wish.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: To activate code in Commandbutton without clic
Reply #3 - Mar 16th, 2008 at 3:26am
Print Post Print Post  
The code is extremely lengthy (1300+ lines with comments) and with so many variables. Would it be advisable to put it in the Global code?  On the top of it Global variables has to be stat variables (outside of subroutine) and itself has many subroutines and userdefined functions in the code.  As such I can accomplish that using RunEntryOnEvent( ) and RemoveOnEntryOnEvent() and sReset variables to break the loop.  Thanks for suggestion however, I will certainly be using the methods you have suggestd somewhere if not in this instance.  Thanks you Bob and Mark.
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: To activate code in Commandbutton without clic
Reply #4 - Mar 16th, 2008 at 1:40pm
Print Post Print Post  
Bharat_Naik wrote on Mar 16th, 2008 at 3:26am:
The code is extremely lengthy (1300+ lines with comments) and with so many variables. Would it be advisable to put it in the Global code? 


Advisable? Yes, certainly. The division of code into subroutines and functions is almost always a good idea. If it is lengthy, look for the points that mark the beginning and ending of new functionality, and make multiple functions and subroutines, maybe even multiple levels of functions and subroutines, and tie them together through invocation. The ideal being to create generic functions that can be used and reused.

If you have many variables that are declared outside of the scope of any one function or subroutine, it is likely that these should be redeclared and placed inside the new subroutines and functions as local variable. Use the parameters and return values of the functions instead to pass information from one subroutine to another. Try to avoid globals, whether static or otherwise.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged