DSJain Posted May 29, 2008 Share Posted May 29, 2008 Hello again, There are some functions written in MS Access design to perform some calculations. Similar functions I have to write in iReport templates. I have no idea like where these function should be written and what should be the syntax. The code in one of the functions is as below. =Sum(somme_rectif([1NBUDGET])) -> The function Call ***************************Function is as below -->************************** Function somme_rectif(bud As Variant) ' Cette fonction calcule la somme des rectifications d'un budget passé ' en paramètre Dim db As Database Dim r As Recordset Dim sql As String Dim t If IsNull(bud) Or IsEmpty(bud) Or bud = "" Then somme_rectif = 0 Exit Function End If t = 0 Set db = CurrentDb() sql = "SELECT DISTINCTROW cRECTIFBUD.cMNET, cRECTIFBUD.cNBUDGET" sql = sql & " FROM cRECTIFBUD" sql = sql & " WHERE ((cRECTIFBUD.cNBUDGET = '" & bud & "') Or (cRECTIFBUD.cNBUDGETDEST = '" & bud & "'));" Set r = db.OpenRecordset(sql) If r.RecordCount > 0 Then r.MoveFirst Do Until r.EOF t = t + IIf(r![cNBUDGET] = bud, r![cMNET], -r![cMNET]) r.MoveNext Loop End If r.Close somme_rectif = t End Function********************************** How to write this function in iReport template and where. Appreciate any kind of help. Thanks a lot !!! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now