Hi
i have to run a query that's based on onother query. I'm trying to get rid of all query and i want to put everything in my code.
tha two query are:
HTML Code:
strSql = "SELECT Portafoglio.CandidatoID, Portafoglio.TrattativaID, Nz([gestito])+Nz([assicurativo])+Nz([gestioni patrimoniali])+Nz([amministrato])+Nz([certificati])+Nz([liquidità]) AS Totale, Switch([totale]<100000,""<100k"",[totale] Between 100000 And 299999,""100k-300k"",[totale] Between 300000 And 499999,""300k-500k"",[totale] Between 500000 And 699999,""500k-700k"",[totale] Between 700000 And 1000000,""700k-1mln"",[totale] Between 1000000 And 1999999,""1mln-2mln"",[totale] Between 2000000 And 4999999,""2mln-5mln"",[totale] Between 5000000 And 9999999,""5mln-10mln"",[totale]>=10000000,"">=10mln"") AS [Taglio cliente], Switch([taglio cliente]=""<100k"",1,[taglio cliente]=""100k-300k"",2,[taglio cliente]=""300k-500k"",3,[taglio cliente]=""500k-700k"",4,[taglio cliente]=""700k-1mln"",5,[taglio cliente]=""1mln-2mln"",6,[taglio cliente]=""2mln-5mln"",7,[taglio cliente]=""5mln-10mln"",8,[taglio cliente]="">=10mln"",9) AS Ordinamento " & vbCrLf & _"FROM Portafoglio " & vbCrLf & _"WHERE (((Portafoglio.TrattativaID)=[Maschere]![home].[sottomascheraspostamento2]![sottomascheraspostamento1].[form]![CCSceltaTrattativa]));"
this is the first query in whitch i made some calculated fields.
then the second query (that's the one i use to populate the form) is
HTML Code:
strSql = "SELECT [DB 1T ptf banca taglio clienti].TrattativaID, [DB 1T ptf banca taglio clienti].CandidatoID, [DB 1T ptf banca taglio clienti].[Taglio cliente], Count([DB 1T ptf banca taglio clienti].[Taglio cliente]) AS [ConteggioDiTaglio cliente], Switch([taglio cliente]=""<100k"",1,[taglio cliente]=""100k-300k"",2,[taglio cliente]=""300k-500k"",3,[taglio cliente]=""500k-700k"",4,[taglio cliente]=""700k-1mln"",5,[taglio cliente]=""1mln-2mln"",6,[taglio cliente]=""2mln-5mln"",7,[taglio cliente]=""5mln-10mln"",8,[taglio cliente]="">=10mln"",9) AS Ordinamento " & vbCrLf & _"FROM [DB 1T ptf banca taglio clienti] " & vbCrLf & _"GROUP BY [DB 1T ptf banca taglio clienti].TrattativaID, [DB 1T ptf banca taglio clienti].CandidatoID, [DB 1T ptf banca taglio clienti].[Taglio cliente], Switch([taglio cliente]=""<100k"",1,[taglio cliente]=""100k-300k"",2,[taglio cliente]=""300k-500k"",3,[taglio cliente]=""500k-700k"",4,[taglio cliente]=""700k-1mln"",5,[taglio cliente]=""1mln-2mln"",6,[taglio cliente]=""2mln-5mln"",7,[taglio cliente]=""5mln-10mln"",8,[taglio cliente]="">=10mln"",9) " & vbCrLf & _"HAVING ((([DB 1T ptf banca taglio clienti].TrattativaID)=[Maschere]![home].[sottomascheraspostamento2]![sottomascheraspostamento1].[form]![CCSceltaTrattativa])) " & vbCrLf & _"ORDER BY Switch([taglio cliente]=""<100k"",1,[taglio cliente]=""100k-300k"",2,[taglio cliente]=""300k-500k"",3,[taglio cliente]=""500k-700k"",4,[taglio cliente]=""700k-1mln"",5,[taglio cliente]=""1mln-2mln"",6,[taglio cliente]=""2mln-5mln"",7,[taglio cliente]=""5mln-10mln"",8,[taglio cliente]="">=10mln"",9);"
now, how can i run the first query and then run the second based on the first query in my vba code?
ps i tried to use the instant sql formatter...don't know if in a correct way