Calling a subroutine on another form

I never knew that you could do this.   I was asked to give some assistance at a friends place of work and was rather startled to come across the following line of code.

'Update the calculated hours shown on the TransactionTotals Form
Call Forms.TransactionTotals.UpdateEmployeeHours

Nice.  I can see how that would be useful at times.   I just setup a routine myself for enabling/disabling command buttons on a main menu from a global options form.  

The called routine needs to be a public routine.  And the forms name can't have any blanks in it.  Or maybe it can but enclosing the form name in square brackets didn't work so i don't know the syntax.

When I have some more time, and I have his permission, I'll document some of the interesting UI we put in that system to make the data entry as clear and rapid as possible.  For example the above TransactionTotals form knows what kind of hours the employee usually works so flags any entries with hours below the standard value in yellow and any entries with hours over the standard values in red.  Of course if the employee has the correct number of hours then it's green.

Published Sunday, July 29, 2007 10:36 PM by Tony
Filed under:

Comments

# re: Calling a subroutine on another form

For completeness:

If your form name has blanks in it, you can use:

Call Forms("Form Name").SubName

Monday, July 30, 2007 7:01 AM by Stuart Radcliffe

# re: Calling a subroutine on another form

Yes, I was thinking I'd try that syntax but never quite got around to it.  Don't know why.

Thanks, Tony

Monday, July 30, 2007 1:36 PM by Tony

# re: Calling a subroutine on another form

Call Forms.BeforeSpace_after.routine

also works (goes for referencing controls as well)

Wednesday, August 01, 2007 3:35 PM by Pieter Wijnen

# re: Calling a subroutine on another form

Pieter, you're right.  I had to use that syntax when opening a form a second time about five years ago.  I had completely forgotten about that.

Thanks, Tony

Wednesday, August 01, 2007 6:49 PM by Tony

Leave a Comment

(required) 
(required) 
(optional)
(required)