07. april 2004 - 02:39Der er
24 kommentarer og 1 løsning
Utrykk som utfører tellinger i rapporter
Jeg har et kjempeproblem...!! Jeg har 40 datoer fra ca 10.01.01 til 01.01.03. Jeg ønsker å lage et utrykk som klarer å telle disse i en rapport. Utfordringen er at den kun skal telle innenfor et visst intervall som jeg har angitt i et skjema som står åpent. Rapporten skal vise alle postene fra år 01 til år 03, men feltet skal kun returnere hvor mange datoer det er innenfor intervallet jeg har angitt i skjemaet.
Intervall feltene er [fra dato] og [til dato] Dato feltet som skal telles er [signert dato]
Jeg har selvsagt kjørt IIF setningen og deretter =antall[signert dato], men da teller den alle postene [signert dato] i rapporten, og ikke bare de innefor intervallet jeg har angitt. Mulig jeg har gjort noe feil der.
Jeg vil alligevel forsøge mig med en VBA-løsning. Det er slet ikke så svært:
1. Jeg antager at du sllerede har 2 ubundne tekstbokse i din formular. De hedder "fra dato" og "til dato".
2. Tag endnu en ubundet tekstboks fra værktøjskassen og navngiv den "antaldage".
3. Tab en kommandoknap fra værktøjskassen. Højreklik på den > Egenskaber > Fanen Hændelser > sæt markøren på linien der hedder VedKlik (Eller blot Click) > Tryk på de 3 små ... i højre side. Nu står markøren i VBA-editoren, her indsætter du flg:
Du skal udskifte "Rapport1" med navnet på den rapport du vil udskrive. Nevnet skal stadig være i ""
4. Åbn din rapport i Designvisning og tag en ubundet Tekstboks fra værktøjslinien og sæt den f.eks i Rapportfoden. Kan du ikke se Rapportfoden, får du den frem fra menulinien Vis > Rapporthoved/Rapportfod. Du behøver ikke at ændre det navn på tekstboksen som Acces har govet den.
5. Højreklik på Tekstboksen > Egenskaber > Fanen Data og på linien Postkilde indtaster du flg:
=Forms!Formular1!antaldage
6. Når du nu åbner rapporten fra formularens kommandoknap, vil rapportens ubundne Tekstboks nu vise antal dage der er imellem formularens feltet fra dato og til dato.
Have I understood the question correctly? You want to see ALL records between 01/01/2002 and 31/12/2003 and you also want to see how many records are between "Intervall feltene er [fra dato] og [til dato]" and the result is to be shown in "[signert dato]"?
Takk for svar, men jeg tror du missforstår problemet mitt litt. Å telle antall dager mellom et intervall er greit nok, men det er ikke intervallene om skal telles, det er antall poster mellom intervallene. La oss si at jeg har følgende datoer som vises i rapporten:
10.01.01 13.01.01 17.01.01 02.02.02 17.02.02
Intervall datoene er fra 11.01.01 til 13.02.02. Dette skal returnere 3 datoer i utrykket og ikke 5. Husk at alle 5 datoer skal vises i rapporten, men kun de 3 innenfor intervallet skal telles med. Jeg vil da ha en ubundet boks som sier 3.
I want to count the number of posts in my report, based on the intervall i have written in my form, that is open in the background. But what the report i showing is undependent from what the interval in the form is saying. ( look above ) The report can show me 20 posts from 01.01.01 to 01.01.04, but i only want to count the dates between 13.02.01 to 02.03.03.
if yiu have a date field in the database named [signert dato] then =DCount("*","[TableName]","[TableName]![signert dato] Between Forms!frmDates![fra Dato] And Forms!frmDates![til Dato]")
you need to alter the name of the table (TableName) to the correct table name, and the name of teh form (frmDates) to the correct form name!
Du spørger: "men feltet skal kun returnere hvor mange datoer det er innenfor intervallet jeg har angitt i skjemaet." Det gør begge mine forslag. Terry's svar giver dig hvad du mente.
Mugs: Slik jeg tolker din forklaring, så returnerer ditt forslag kun hvor mange dager det er mellom intervallet, og ikke hvor mange poster det er innenfor intervallet. Beklager dårlig forklaring fra min side der der.
Terry: I tryed this:
=DCount("*","[signert all]","[signert all]![signert dato] Between Forms![rapport oversikt]![fra Dato] And Forms![rapport oversikt]![til Dato]")
"Signert all" is my table name where "signert dato" field is placed, but don`t i need this table to be open to refer to it... ?? What do you mean with tabel name then ...?? Is it the name of the report you want me to type in there ?
Anyways this string did not work. Something is wrong with the spelling or som letters is missing. I tryed all kombinasjons and so on. It think this might be the korrekt soulution to my problem, so i relly want this to work right. Thanks !!
I want to count surten posts in a total fo many post setts.
You gave me this string:
=DCount("*","[TableName]","[TableName]![signert dato] Between Forms!frmDates![fra Dato] And Forms!frmDates![til Dato]")
and i tryed this string that should be simulare to yours:
=DCount("*","[signert all]","[signert all]![signert dato] Between Forms![rapport oversikt]![fra Dato] And Forms![rapport oversikt]![til Dato]")
"Signert all" is my table name where "signert dato" field is placed, but don`t i need this table to be open to refer to it... ?? What do you mean with tabel name then ...?? Is it the name of the report you want me to type in there ?
Anyways this string did not work. Something is wrong with the spelling or som letters is missing. I tryed all kombinasjons and so on.
ok....! The only problem now is that the string is counting the number of values in the table, and not in the report. You see, i got this report, with a subreport, and the main report is controled by my emploies, and the sub report is their working dates. It means that all the dates in my table is spread over many emploies, and i want to count the number of dates ( that are still inside the intervalls ) for each emploie in the sub report.
I think you are going to have to explain a bit more! I understood that the report was to show all records, but the count was to be on the date inteval from the form! In the report you sent, this was not filtered for a single employee, is this what you want?
Yes, my main report is the emploies, and the subreport is their working dates, and i want the string to count the dates for each employee in the subreport, and not the total of all amployees !
The report i sendt you was somethin i made for the question, because the orginal project im working on is not to be distrubied to people that are not in the project. It`s a secret or somethin... !!
It sounds to me as though this is an entirely different question! Is it possible for you to send me the dB which you want altering, and an explanation (example) of what you want to see in the report/sub report.
I'm off out for a short time but will take a look as soon as possible
do you want to see the number of records which are shown on the sub report for each employee, or do you only want to see the number of records between the date interval?
I want to see the number of records, seperatly for each employee, between the date interval. It means if i have 3 employees, i want 3 values ( counts ).
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.