I just found this forum, so I hope I'm in the right place and someone can help me.
I am converting data for an educational institution and I need to supply a class rank (freshman, sophomore) based on the earned credits. The old database doesn't have the class rank, and the new database requires it.
I wrote the following function that is behaving strangely:
Function run_total(id, crdearned As Integer) As Integer
Static beg_credit As Integer
Static new_id As Integer
Static first_row As Integer
If first_row = 0 Then
new_id = id
first_row = 1
End If
If id = new_id Then
If crdearned > 0 Then beg_credit = beg_credit + crdearned
run_total = beg_credit
Else: beg_credit = 0
run_total = 0
If crdearned > 0 Then beg_credit = crdearned
run_total = beg_credit
new_id = id
End If
End Function
The function is called in the query field this way:
class: (run_total([load_id],[crdearned]))
In debug mode, the first id passes through perfectly. Halfway through the second id, the process hangs. If I click on the query tab to view the results, the debugger restarts and the id has reverted back to the first id. If I follow along for awhile, the data in final result shows the data using the first id, but the id field in the result increments properly. So I have a function that just won't work and I don't know why.
Thanks in advance!
Ken
I am converting data for an educational institution and I need to supply a class rank (freshman, sophomore) based on the earned credits. The old database doesn't have the class rank, and the new database requires it.
I wrote the following function that is behaving strangely:
Function run_total(id, crdearned As Integer) As Integer
Static beg_credit As Integer
Static new_id As Integer
Static first_row As Integer
If first_row = 0 Then
new_id = id
first_row = 1
End If
If id = new_id Then
If crdearned > 0 Then beg_credit = beg_credit + crdearned
run_total = beg_credit
Else: beg_credit = 0
run_total = 0
If crdearned > 0 Then beg_credit = crdearned
run_total = beg_credit
new_id = id
End If
End Function
The function is called in the query field this way:
class: (run_total([load_id],[crdearned]))
In debug mode, the first id passes through perfectly. Halfway through the second id, the process hangs. If I click on the query tab to view the results, the debugger restarts and the id has reverted back to the first id. If I follow along for awhile, the data in final result shows the data using the first id, but the id field in the result increments properly. So I have a function that just won't work and I don't know why.
Thanks in advance!
Ken