QUERRY: WHAT'S THE PROBLEM???

FlavioT

New Member
Joined
Feb 11, 2003
Messages
40
Hi!! I'm getting crazy here... I'm trying to put a limit to the values... This first SQL works great... But when I try to link the HAVING condition to a Form it show all the records!! WHY?

What is [Formulários] is my Portuguese Access for Forms.
And YES... this object exists!

Does anyone have a clue?????? :rolleyes:
SQL1: Works great!
SELECT DISTINCTROW CPF.Nome, CPF.CPF, Sum([valor])-Sum([valor pago]) AS Dev, Count(CPF.CPF) AS ContarDeCPF
FROM CPF INNER JOIN Cheques ON CPF.CPF = Cheques.CPF
GROUP BY CPF.Nome, CPF.CPF
HAVING (((Sum([valor])-Sum([valor pago]))>2000))
ORDER BY Sum([valor])-Sum([valor pago]) DESC;

SQL2: Doesn't work!
SELECT DISTINCTROW CPF.Nome, CPF.CPF, Sum([valor])-Sum([valor pago]) AS Dev, Count(CPF.CPF) AS ContarDeCPF
FROM CPF INNER JOIN Cheques ON CPF.CPF = Cheques.CPF
GROUP BY CPF.Nome, CPF.CPF
HAVING (((Sum([valor])-Sum([valor pago]))>[Formulários]![Formulário1]![Texto0]))
ORDER BY Sum([valor])-Sum([valor pago]) DESC;
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
"Having" can sometime give erratic results. I find it best to use "where" as opposed to having. On your join you may wnat to force all of the records from on table and show only the matching records in the other table. Do that by including bith queries in a new query link them by dragging your join field and then right click the join line and select a join that will force the records from one table. Try it a few different ways, it might work for you.
 
Upvote 0

Forum statistics

Threads
1,221,680
Messages
6,161,251
Members
451,692
Latest member
jmaskin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top