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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with SQL query

Status
Not open for further replies.

ahau

Programmer
Apr 19, 2006
51
AU
Hi

I was wondering if anyone might be able to help me. I was trying to calculate for the gross payment by adding up the sum of net_pay and the sum of tax_pay.

I've got the following error message

runtime error '-2147217900 (80040e14)'
Syntax error in FROM clause

when trying to run the following code

'Set row source for list box
StrSQL = "SELECT Salary.Staff_ID, Salary.Tax_Amount, Salary.Net_Amount, Salary.Date1 "
StrSQL = StrSQL & "FROM Salary "
StrSQL = StrSQL & "WHERE Salary.Staff_ID like '" & Me.CB_StaffID & "' AND Salary.Date1 Between #1/1/2005# And #1/1/2006# ORDER BY Salary.Date1"

rsNew.Open StrSQL, CurrentProject.Connection, adOpenDynamic, adLockOptimistic

Do Until rsNew.EOF
mytot_taxpay = mytot_taxpay + rsNew!Tax_Amount
mytot_netpay = mytot_netpay + rsNew!Net_Amount
Loop

Me.TB_GrossSalary = mytot_taxpay + mytot_netpay ' total gross pay for the staff

rsNew.Close

Any ideas?

Thank you for your help in advance
 
I think it would be much easier to use DSum.

You say:
like '" & Me.CB_StaffID & "' <...>

What does CB_StaffID contain?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top