Modules, Aaaarrrggghhhhh

fatbloater

Registered User.
Local time
Today, 08:15
Joined
Sep 28, 2004
Messages
36
I am having a nightmare! I have a main form; on this form i have 10 sub forms.
Each of these sub forms has the same fields and a button.
I need a module that i can run from this button and will conduct calculations using the fields in the sub form and putting the result into another field on the sub form e.g. field_a = field_b + field_c.
I could do each form separately but then i would be duplicating code, please help!!!
 
Hi,

if You don't have, You create a new Module, write their Your calculation routine. In the button_Click event You launch this function an ready.

Hope, that will help. ;)

Agnostiker
 
This what i have written, the text boxes contain numbers:

Public Function text_calc()
text3 = text1 - text2
End Function

Then on the button i have:

Private Sub Command6_Click()
text_calc
End Sub

I know this is wrong, when i check the function it does not error, maybe i am calling it wrong.
 
I understood, You will use this function for all the subforms? So give the values to the function as parameters and let the function return the result.

Agnostiker
 
I will use this function on all sub forms.
How do i do what you have suggested, can you give me an example?
 
Last edited:
I have the forms represnting a layout in an office, its purley for looks not for functionality.
 
I have the forms represnting a layout in an office, its purley for looks not for functionality.

Then get rid of them. Sounds like a cluster...

???
kh
 
...like this?

Function Calculate(A As Integer, B As Integer) As Integer 'declared in a standard module
Calculate=A+B​
End Function

Private Sub Button_Name_Click() 'This is in your formular
Me.TextBox_Result.Value=Calculate(Me.TextBox_A.Value, Me.TextBox_B.Value)​
End Sub



Agnostiker
 
Thank you . That worked just how i wanted it! Much appreciated.
 

Users who are viewing this thread

Back
Top Bottom