Ovenstående spørgsmål er besvaret men indeholder den nødvendige info til at besvare mit tillægsspørgsmål:
Jeg har behov for at kunne afgrænse statistiken fra ovenstående til en given tidsramme, typisk et år men helst bare ved angivelse af fra og til dato.
Derudover skal jeg lige ha' på det rene hvordan jeg vha. en dropdown liste med institutioner kan få min form til kun at vise statistik på denne institution.
I dette særtema ser vi på, hvordan cloud og AI bliver fundamentet for virksomhedernes digitale forretning, og hvordan de nye muligheder for automatisering og forretningsværdi kan udnyttes uden at miste overblik, sikkerhed og menneskelig kontrol.
For at afgrænse statistikken til en periode, må du jo nødvendigvis have et datofelt, der angiver datoen for en konsultation. Når du har det, kan du i forespørgslen angive et kriterie ved hjælp af det reserverede ord Between. I datofeltet i forespørgslens kriterielinie skriver du:
Between [Indtast første dato:] And [Indtast sidste dato:]
De 4-kantede paranteser angiver, at du promptes for en indtastning, valget af tekst indenfor paranteserne er fri.
M.h.t. din dropdown, kan du i forespørgslens felt vedr. institutioner, skrive et kriterie der henviser til formularen's combo:
SELECT I.ID, I.Navn, (SELECT Count(S.ID) AS CountOfID FROM Sager AS S WHERE (S.Institution = I.ID AND ((S.Konsultationer)<=3) AND ((S.ID) In (SELECT K.Sag AS ID FROM Klienter AS K GROUP BY K.Sag HAVING Count(K.ID)=1)))) AS 3KonsEnKlient, (SELECT Count(S.ID) AS CountOfID FROM Sager AS S WHERE (S.Institution = I.ID AND ((S.Konsultationer)<=5) AND ((S.ID) In (SELECT K.Sag AS ID FROM Klienter AS K GROUP BY K.Sag HAVING Count(K.ID)=1)))) AS 5KonsEnKlient, (SELECT Count(S.ID) AS CountOfID FROM Sager AS S WHERE (S.Institution = I.ID AND S.ID In (SELECT K.Sag AS ID FROM Klienter AS K GROUP BY K.Sag HAVING Count(K.ID)=1))) AS TotKonsEnKlient, (SELECT Count(S.ID) AS CountOfID FROM Sager AS S WHERE (S.Institution = I.ID AND ((S.Konsultationer)<=1) AND ((S.ID) In (SELECT K.Sag AS ID FROM Klienter AS K GROUP BY K.Sag HAVING Count(K.ID)>1)))) AS 1KonsFlereKlienter, (SELECT Count(S.ID) AS CountOfID FROM Sager AS S WHERE (S.Institution = I.ID AND ((S.Konsultationer)<=2) AND ((S.ID) In (SELECT K.Sag AS ID FROM Klienter AS K GROUP BY K.Sag HAVING Count(K.ID)>1)))) AS 2KonsFlereKlienter, (SELECT Count(S.ID) AS CountOfID FROM Sager AS S WHERE (S.Institution = I.ID AND S.ID In (SELECT K.Sag AS ID FROM Klienter AS K GROUP BY K.Sag HAVING Count(K.ID)>1))) AS TotKonsFlereKlienter, CLng(nz((SELECT Sum(S.Konsultationer) AS KonsAntal FROM Sager AS S WHERE (S.Institution = I.ID AND ((S.ID) In (SELECT K.Sag AS ID FROM Klienter AS K GROUP BY K.Sag HAVING Count(K.ID)=1)))),0)) AS KonsAntalEnKlient, CLng(nz((SELECT Sum(S.Konsultationer) AS KonsAntal FROM Sager AS S WHERE (S.Institution = I.ID AND ((S.ID) In (SELECT K.Sag AS ID FROM Klienter AS K GROUP BY K.Sag HAVING Count(K.ID)>1)))),0)) AS KonsAntalFlereKlienter FROM Institutioner AS I;
TO
SELECT I.ID, I.Navn, (SELECT Count(S.ID) AS CountOfID FROM Sager AS S WHERE ((S.Modtaget BETWEEN [FORMS]!frmDateInterval.txtFra AND [FORMS]!frmDateInterval.txtTil) AND S.Institution = I.ID AND ((S.Konsultationer)<=3) AND ((S.ID) In (SELECT K.Sag AS ID FROM Klienter AS K GROUP BY K.Sag HAVING Count(K.ID)=1)))) AS 3KonsEnKlient, (SELECT Count(S.ID) AS CountOfID FROM Sager AS S WHERE ((S.Modtaget BETWEEN [FORMS]!frmDateInterval.txtFra AND [FORMS]!frmDateInterval.txtTil) AND S.Institution = I.ID AND ((S.Konsultationer)<=5) AND ((S.ID) In (SELECT K.Sag AS ID FROM Klienter AS K GROUP BY K.Sag HAVING Count(K.ID)=1)))) AS 5KonsEnKlient, (SELECT Count(S.ID) AS CountOfID FROM Sager AS S WHERE ((S.Modtaget BETWEEN [FORMS]!frmDateInterval.txtFra AND [FORMS]!frmDateInterval.txtTil) AND S.Institution = I.ID AND S.ID In (SELECT K.Sag AS ID FROM Klienter AS K GROUP BY K.Sag HAVING Count(K.ID)=1))) AS TotKonsEnKlient, (SELECT Count(S.ID) AS CountOfID FROM Sager AS S WHERE ((S.Modtaget BETWEEN [FORMS]!frmDateInterval.txtFra AND [FORMS]!frmDateInterval.txtTil) AND S.Institution = I.ID AND ((S.Konsultationer)<=1) AND ((S.ID) In (SELECT K.Sag AS ID FROM Klienter AS K GROUP BY K.Sag HAVING Count(K.ID)>1)))) AS 1KonsFlereKlienter, (SELECT Count(S.ID) AS CountOfID FROM Sager AS S WHERE ((S.Modtaget BETWEEN [FORMS]!frmDateInterval.txtFra AND [FORMS]!frmDateInterval.txtTil) AND S.Institution = I.ID AND ((S.Konsultationer)<=2) AND ((S.ID) In (SELECT K.Sag AS ID FROM Klienter AS K GROUP BY K.Sag HAVING Count(K.ID)>1)))) AS 2KonsFlereKlienter, (SELECT Count(S.ID) AS CountOfID FROM Sager AS S WHERE ((S.Modtaget BETWEEN [FORMS]!frmDateInterval.txtFra AND [FORMS]!frmDateInterval.txtTil) AND S.Institution = I.ID AND S.ID In (SELECT K.Sag AS ID FROM Klienter AS K GROUP BY K.Sag HAVING Count(K.ID)>1))) AS TotKonsFlereKlienter, CLng(nz((SELECT Sum(S.Konsultationer) AS KonsAntal FROM Sager AS S WHERE ((S.Modtaget BETWEEN [FORMS]!frmDateInterval.txtFra AND [FORMS]!frmDateInterval.txtTil) AND S.Institution = I.ID AND ((S.ID) In (SELECT K.Sag AS ID FROM Klienter AS K GROUP BY K.Sag HAVING Count(K.ID)=1)))),0)) AS KonsAntalEnKlient, CLng(nz((SELECT Sum(S.Konsultationer) AS KonsAntal FROM Sager AS S WHERE ((S.Modtaget BETWEEN [FORMS]!frmDateInterval.txtFra AND [FORMS]!frmDateInterval.txtTil) AND S.Institution = I.ID AND ((S.ID) In (SELECT K.Sag AS ID FROM Klienter AS K GROUP BY K.Sag HAVING Count(K.ID)>1)))),0)) AS KonsAntalFlereKlienter FROM Institutioner AS I;
(3) On the form I've added a subform which should display the results of the qryTerry2. But after i click my "generate
-statistics-button", the data isn't updated. Requery doesn't seem to work either, but if i manually right click the
subform and select "Remove Filter/Sort" the data shows. How do i this from the function of the button?
(4) Forgot one damn thing again regarding the query! :) - But perhabs you just need to clear me out on the syntax... How do one add, multiply and divide the values returned from your query in another column? E.g. "3KonsIndividuel/TotKonsEnKlient*100" would give the percentage of Sager closed within 3 konsultations.
Question 1: If the “sager” isn’t afsluttet then the date is NULL which isn’t the same as “” (empty) > it doesn’t exist!
So you have to test for NOT NULL. (WHERE (NOT S.afsluttet Is Null) AND …..) I have included an example for the first field (qryTerryAfsluttetSagerDEMO), I’m sure you can see how it works!
Question 2: Well its hard to give an answer here as you don’t say what you are trying to do! I can only take a wild guess :o)
Question 3: I don’t see a button named “generate-statistics-button"! and if I right click on the sub form to remove the filter is STILL don’t get any records! How can this be?
Well try opening the query directly, but still entering the date interval and institution. You still get no records, correct? Well if I understand your question correctly (Q3) then it is because the query only shows records where “sager” is afsluttet, and because NONE are afsluttet you will see no records :o)
Question 4: Take a look at the last field in the DEMO query “qryTerryAfsluttetSagerDEMO”
No, don't worry Terry! However I was delayed in testing this, as my client in the last minute while finishing the statistics thing, changed their minds in a way that ruins the foundation of my question 2 U!! :( :(
So the past days I've been busy changing what they want, and am about to modify your solutions to fit the new structure.
Sorry Terry, but I do have other things than this f*cking project to do - and like I said the changed their freakin' procedures. However, I edited to fit the new way so thanks for your help and happy new year to you to! :)
just got back from England, I'll take a look as soon as I'm up and running again, thats if you dont have an answer by then :o)
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.