VB problem in Modules

T

Tom Hagen

I've been trying to figure out how to do this in either
Access or Excel 2000 but to much has changed and the
coding I'm use to in Access 95/97 is not working. Can
someone please look at the code and tell me whats wrong?
I can also send both the excel and access files to see
what I'm trying to do and compare.

Here is the code:


Public Function Find_Fed_Tax(MS As String, PP As String,
TI As Currency) As Currency
'MS is Marriage Status, PP is Payroll Period, TI is
Taxable Income which is figured out from the W2 form.

'Create a connection to the current Database
Dim db As ADODB.Connection
Set db = CurrentProject.Connection

'Create a Recordset from the table Federal Tax
Dim rstFT As New ADODB.Recordset
rstFT.Open "Federal Tax", db, adOpenKeyset,
adLockOptimistic, adCmdTableDirect

'Create a temp storage location for the info needed to do
the math
Dim rstMS As New ADODB.Recordset

'Using the old method of recordset to try and create the
temp numbers needed
Set rstFFT = db.OpenRecordset("Select * FROM '" & rstFFT
& "' WHERE [Marriage Status]= '" & MS & "'And [Payroll
Period]= '" & PP & "' And [Over]<='" & TI & "' And [Not
Over]>'" & TI & "'")

'Do the math for the amount to be taxed
Find_Fed_Tax = rstFFT![Income tax to withhold] + (TI -
rstFFT![Over]) * rstFFT![% to withhold]

End Function


Thanks for the help.

Tom Hagen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top