By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,504 Members | 1,583 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,504 IT Pros & Developers. It's quick & easy.

Subroutines in a Form

P: n/a
I have a form with thirty text boxes.
Each of them has an input mask of 99.

In each text box the user enters a numeric score in the range from 0 to 99.

As each text box loses focus I want to perform a calculation involving all
the numbers (ok the string representation of the numbers) . It doesn't
matter which text box loses focus, the calculation is the same.

Can I declare (define) a subroutine (Procedure ?) and call it from the lost
focus event of each text box .

I suspect I can but when I looked for details I couldn't find any.

Thanks
Jul 10 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Mon, 10 Jul 2006 23:42:38 GMT, "RICHARD BROMBERG" <no*****@att.netwrote:
>I have a form with thirty text boxes.
Each of them has an input mask of 99.

In each text box the user enters a numeric score in the range from 0 to 99.

As each text box loses focus I want to perform a calculation involving all
the numbers (ok the string representation of the numbers) . It doesn't
matter which text box loses focus, the calculation is the same.

Can I declare (define) a subroutine (Procedure ?) and call it from the lost
focus event of each text box .

I suspect I can but when I looked for details I couldn't find any.

Thanks
In the form's module create a FUNCTION.

'================================================= ======
Function fDoCalc()

'write your routine here to do whatever calculations you require.

Me.txtResult = Me.txt1 + Me.txt2 + Me.txt3

End Function
'================================================= ======

In the property sheet of the form, select each of your 30 text boxes and in the
LostFocus event put -
=fDoCalc()

The function will be triggered each time any of the text boxes loses the focus.
Wayne Gillespie
Gosford NSW Australia
Jul 11 '06 #2

P: n/a
Hi,

Perhaps it's more efficient to run this function at the AfterUpdate
event, thus after editing. (Unless you use VB-code to fill the text
boxes)

HBInc.
Wayne Gillespie wrote:
On Mon, 10 Jul 2006 23:42:38 GMT, "RICHARD BROMBERG" <no*****@att.netwrote:
I have a form with thirty text boxes.
Each of them has an input mask of 99.

In each text box the user enters a numeric score in the range from 0 to 99.

As each text box loses focus I want to perform a calculation involving all
the numbers (ok the string representation of the numbers) . It doesn't
matter which text box loses focus, the calculation is the same.

Can I declare (define) a subroutine (Procedure ?) and call it from the lost
focus event of each text box .

I suspect I can but when I looked for details I couldn't find any.

Thanks

In the form's module create a FUNCTION.

'================================================= ======
Function fDoCalc()

'write your routine here to do whatever calculations you require.

Me.txtResult = Me.txt1 + Me.txt2 + Me.txt3

End Function
'================================================= ======

In the property sheet of the form, select each of your 30 text boxes and in the
LostFocus event put -
=fDoCalc()

The function will be triggered each time any of the text boxes loses the focus.
Wayne Gillespie
Gosford NSW Australia
Jul 11 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.