06. januar 2005 - 12:11Der er
15 kommentarer og 2 løsninger
Tælle record i forespørgsel
Hej..
SELECT ("ved ikke hvad") AS afsnit, tblDVDindenhold.DVDID, tblDVDindenhold.afsnitBeskrivelse FROM tblDVDindenhold WHERE (((tblDVDindenhold.DVDID)=1));
I følgende forespørgsel får jeg x antal record. Jeg ville nu gerne have at der kom til at stå i felt "afsnit" 1, 2, 3 osv det antal som forespørgslen giver.
Det kan du terry (og andre)ha ha sikkert hjælpe mig med.
I dette særtema om aspekter af AI ser vi på skiftet fra sprogmodeller til AI-agenter, og hvordan virksomheder kan navigere i spændet mellem teknologisk hastighed og behovet for menneskelig kontrol.
The following example returns the number of orders shipped to the United Kingdom after January 1, 1995. The domain is an Orders table. The criteria argument restricts the resulting set of records to those for which ShipCountry equals UK and ShippedDate is greater than 1-1-95.
intX = DCount("[ShippedDate]", "Orders", _ "[ShipCountry] = 'UK' AND [ShippedDate] > #1-1-95#") In the next example, the criteria argument includes the current value of a combo box called ShipCountry. The values in the ShipCountry combo box come from the field ShipCountry in an Orders table. Note that the reference to the control isn't included in the quotation marks that denote the strings. This ensures that each time the DCount function is called, Microsoft Access will obtain the current value from the control.
Do you have a primary key in the table (autonumber)? There MUST be a field which is unique and possible to sort on before you can do this! If you can send me your dB then I can take a look this evening eksperten@NOSPAMsanthell.dk remove NOSPAM
SELECT (Select count(*) from tblDVDindenhold AS T1 WHERE T1.DVDindenholdID < tblDVDindenhold.DVDindenholdID)+1 AS afsnitnr, tblDVDindenhold.DVDindenholdID, tblDVDindenhold.afsnitBeskrivelse, tblDVDindenhold.DVDID FROM tblDVDindenhold;
Change the sub forms record source to the followwing SQL.
SELECT (Select count(*) from tblDVDindenhold AS T1 WHERE T1.DVDindenholdID < tblDVDindenhold.DVDindenholdID AND T1.DVDID = Forms![tblDVDcover]![DVDId] )+1 AS afsnitnr, tblDVDindenhold.DVDindenholdID, tblDVDindenhold.afsnitBeskrivelse, tblDVDindenhold.DVDID FROM tblDVDindenhold;
T1 is just an alias for tblDVDindenhold Becuase the same table is used in a SUB select its necessary to do this so that it is possible to distinguish between them. Its also easier to write T1 instead of tblDVDindenhold
You can also do this with fields for example: .. AS afsnitnr ...
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.