Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Older Acc97 code no longer works

Status
Not open for further replies.

JackR

IS-IT--Management
Jun 7, 2001
10
0
0
US
Hi,

Have a check printing routine - where the check register no longer prints correctly (check number no longer increments). The register's check number is based upon the number of lines detail section can handle - 92. A temporary table is created by a SQL command (Access 2000) that calls a function that no longer calculates the check number at all (returns zero). What was changed in Access 2000 that would preclude a piece of earlier code from working?

Here is the SQL Statement_______________________

SELECT DISTINCT Sum(VOUCHERS.VoucherAmount) AS SumOfVoucherAmount, Count(VOUCHERS.VoucherAmount) AS CountOfVouchers, Vouchers.AName, forms!main!unbcheck + increment(CountOfVouchers) AS CheckNum INTO temptable
FROM VOUCHERS LEFT JOIN Attorneys ON VOUCHERS.AName = Attorneys.AName
WHERE (((VOUCHERS.Status)='A'))
GROUP BY VOUCHERS.AName
ORDER BY VOUCHERS.AName;

- unbcheck - is the starting check number,
- increment(CountOfVouchers) is the function that is passed the number of detail lines on the 'checkstub'.

Here is the increment() function ___________________
(that no longer seems to work)
________________________________
Option Explicit
Dim incval As Integer
________________________________
Public Function increment(pvar As Variant) As Integer
Dim fitnum As Integer ' <<<This is the number of vouchers per check page>>>
fitnum = 93

Select Case pvar
Case 1 To fitnum
incval = incval + 1
Case (1 * (fitnum)) + 1 To (2 * (fitnum))
incval = incval + 2
Case (2 * (fitnum)) + 1 To (3 * (fitnum))
incval = incval + 3
Case (3 * (fitnum)) + 1 To (4 * (fitnum))
incval = incval + 4
Case Else
End Select

End Function
_________________________________________
This returns nothing but Zero....

What changed in Access 2000 ??

Thanks
 
Your increment function seems to be missing a line at the end:
increment = incval
Since you didn't assign any value to the function result, it returns the initialized value, 0.

Don't ask me how the line got lost, though. Rick Sprague
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top