King_kamikaze
Registered User.
- Local time
- Today, 19:42
- Joined
- Jan 13, 2005
- Messages
- 48
Hello Guys & Gals,
I have function that gets called thousands of times throughout a process, the method i am currently using envolves opening and closing the recordset per interation. The reason i do this is because the criteria changes per time.
Here is the code, i am a self taught coder so some of my methods might not be up to scratch, please let me know if there is any confusion!!! the actual recordset is declared at module level as well!!!
So basically... i would love to streamline this function because it takes AGES to open and close the record set a few thousand times!!!
Many thanks
Tim
I have function that gets called thousands of times throughout a process, the method i am currently using envolves opening and closing the recordset per interation. The reason i do this is because the criteria changes per time.
Here is the code, i am a self taught coder so some of my methods might not be up to scratch, please let me know if there is any confusion!!! the actual recordset is declared at module level as well!!!
Code:
Private Function IP(dblAcc As Double) As Integer
Dim dblAppNum As Double
Dim blnFound As Boolean
rstG_App.Open "SELECT * FROM App as a WHERE a.acc_num_mst LIKE '%" & dblAcc & "%'; ", CurrentProject.Connection, adOpenStatic, adLockOptimistic
If rstG_App.RecordCount > 0 Then
dblAppNum = rstG_App.Fields("app_num").Value
rstG_AppFeePmt.Open "SELECT * FROM App_Fee_Pmt as a WHERE a.app_num LIKE '%" & dblAppNum & "%' ;", CurrentProject.Connection, adOpenStatic, adLockOptimistic
If rstG_AppFeePmt.RecordCount > 0 Then
Do Until rstG_AppFeePmt.EOF Or blnFound = True
If rstG_AppFeePmt.Fields("fee_grp_typ_cod").Value = "003" Then
If 0 - rstG_AppFeePmt.Fields("pmt_clt_amt").Value = rstSAP.Fields("Amount").Value Then
IP = 4
blnFound = True
Else
If rstG_AppFeePmt.Fields("pmt_clt_amt").Value = rstSAP.Fields("Amount").Value Then
'****** Try to create a refund routine!!!******
IP = 7
blnFound = True
Else
IP = 5
blnFound = True
End If
End If
End If
rstG_AppFeePmt.MoveNext
Loop
Else
IP = 5
End If
rstG_AppFeePmt.Close
Else
IP = 6
End If
rstG_App.Close
End Function
So basically... i would love to streamline this function because it takes AGES to open and close the record set a few thousand times!!!
Many thanks
Tim
Last edited: