Help Creating a Function

aqif

Registered User.
Local time
Today, 23:12
Joined
Jul 9, 2001
Messages
158
Hi All
smile.gif


I want to create a dynamic function which can work with any field. As an example I want to create a function calculating Tax Amount. Following calculation will be in the function

Public Function Tax_Amt()

Tax_Amt = Total_Amount - (Total_Amount * 2.5)

End Function

The problem is that every database has got different filed names. I want to create a function and then use it like

Private Sub MyField_Enter()
tax_Amt(MyField)
End Sub

And it should perform the above calculation. I want to use a function which can be used on any form with any numerical field. I dont know I m making much sense or not but this is just an example in order for me to learn. Any detailed explanation will be much appreciated.

Cheers!
Aqif
 
Hi Aqif,

looks like you've pretty much got the answer in your question.

You'd make a function that would take a figure as a parameter. eg
Code:
Public Function Tax_Amt(dblTotalAmount as Double) as Double

   Tax_Amt = dblTotalAmount - (dblTotalAmount * 2.5)

End Function

then you'd just call it from your form/query etc.

me.txtTaxPerc=Tax_Amt(VarName_OrFigure)

To call it in a query you can put something like

Tax_Amount: Tax_Amt(FieldName)
in the field row of the QBE grid

HTH

Drew

[This message has been edited by KDg (edited 07-16-2001).]
 
Heyyy!!!! Why I m not seeing any reply.?? When it is showing Replies as 1

Aqif
 
sorryyyy
smile.gif
Now i see the reply
 

Users who are viewing this thread

Back
Top Bottom