30. juli 2001 - 10:48Der er
15 kommentarer og 1 løsning
Tilskrive værdi med 1 ved læsning
Kan man ikke automatisk tilskrive indholdet i et felt med \"1\" hvergang der bliver spurgt på en record?
Min SQL ser ud som følger:
SELECT Annonce.AnnonceID, Annonce.Grafik FROM Annonce INNER JOIN AnnonceType ON Annonce.AnnonceID = AnnonceType.AnnonceID WHERE ((([AnnonceType]![AnnonceStoerrelseID])=1) AND (([AnnonceType]![AnnoncePlaceringID])=1));
Feltet der skal tilskrives hedder: Hitsafviklet og er placeret i tabellenAnnonce.
If you make a query you can call a module(function) which could do this for you.
make your function in a module and callit say tilskrive. Alter you query to something like:
SELECT Annonce.AnnonceID, Annonce.Grafik, tilskrive() as tilsk FROM Annonce INNER JOIN AnnonceType ON Annonce.AnnonceID = AnnonceType.AnnonceID WHERE ((([AnnonceType]![AnnonceStoerrelseID])=1) AND (([AnnonceType]![AnnoncePlaceringID])=1));
Jeg har nu oprettet en Makro (er det ikke det jeg skal?) med indholdet: UPDATE ANNONCE SET HitsAfviklet = HitsAfviklet + 1
Og min SQL: SELECT Annonce.AnnonceID, Annonce.Grafik, visbanner() AS Udtryk1 FROM Annonce INNER JOIN AnnonceType ON Annonce.AnnonceID = AnnonceType.AnnonceID WHERE ((([AnnonceType]![AnnonceStoerrelseID])=1) AND (([AnnonceType]![AnnoncePlaceringID])=1));
Og til sidst min fejlmeddelse ;-) \"DER ER EN IKKE DEFINERET FUNKTION I UDTRYKKET!\"
macro, never touch em! No, a module with a function. In modules select new, then from the menu select INSERT PROCEDURE and give the new procedure the name visbanner.
In code enter.. DoCmd.RunSQL \"UPDATE ANNONCE SET HitsAfviklet = Hitsafviklet + 1\"
soenderup> Your still going to have problems though! You CANT update att thesame time your selecting on the record. Another solution is to put your hit sin another tabel!
soenderup> looking closer at your problem, this is maybe not the correct way to do this. If I understand you problem, you want to update a specific \"annonce\" record when it gets opened, I was thinking that it was another record. So as things are now, you cant! I still would suggest that you moce your hits to another tabel using the primary key (annonceID) as the primary key in the hits table.
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.