19. oktober 2008 - 18:43Der er
27 kommentarer og 1 løsning
Reset tæller med anden tæller
Jeg har problemer med kode som skal erstatte "If TlrL Opdateres. Hvis TlrL tæller fra f.eks. 23 til 24 skal TlrITEM resættes til 1.
DoCmd.SetWarnings False "If TlrL Opdateres" Then DoCmd.RunSQL "UPDATE TællerITEM SET Nr=1" Else DoCmd.RunSQL "UPDATE TællerITEM SET Nr=Nr+1" End If DoCmd.SetWarnings True
Teknologi, AI og forretning er i centrum på Computerworlds Cloud og AI Festival i København d. 18. og 19. september. Se hele programmet for den store konference om strategisk brug af Cloud og AI på: www.cloud-festival.dk
No it is not code. What I mean is - If "CounterL"(TlrL) changes from ex. 23 to 24, "CounterITEM"(TællerITEM) should reset to "1". "If TlrL Opdateres" is my wording and should be replaced by code.
No! "TællerItem" skal resættes til 1, hvis "TællerL" skifter fra f.eks.23-24 eller 2-3.Med andre ord skifter værdi.Eksempel "If TlrL Opdateres" er pseudo, som skal er erstattes med rigtig kode.
Ja, "TællerITEM" skal resættes til 1 når "TællerL" skifter værdi.Der er tale om 2 forskellige tællere som bliver aktiveret ved ved forskellige hændelser.
This is the code for form A "after insert": DoCmd.SetWarnings False If Tlr = 9999999 Then DoCmd.RunSQL "UPDATE TællerL SET Nr=1" Else DoCmd.RunSQL "UPDATE TællerL SET Nr=Nr+1" End If DoCmd.SetWarnings True and same frame for form B
You should try giving us the FULL story from the start, thi swill help use find a solution. There has been no mention of different forms, and now we see code where Llr has to be 9999999 before it gets reset to 1.
Explain which tables/fields you have and what needs to get updated under which circumstances.
In your comment 19/10-2008 20:22:41 there is nothing which resets TællerITEM which you refer to in your comment 19/10-2008 20:35:32
I will try TblA with field "LOG NO" which is updated by FormA field "LOG NO" which is updated by TællerL. TblB with field "ITEM" which is updated by FormB field "ITEM" which is updated by TællerITEM. Everytime you open a new record in TblA the field "LOG NO" will increase with 1.( 1-2-3.....) Everytime you open a new record in TblB the field "ITEM" will increase with 1.( 1-2-3-4....)As long as you don´t open a new record in TblA. If you open a new record in TblA, the field "ITEM" should reset to "1". (TællerITEM should be reset)
The figures 9999999 could as well be 100,the code comes from another place and should not be used here. I only want to reset TællerITEM to "1" if I open a new record in TblA.
sorry, I dont seem to have received any mails from your comments d.19.
I'm getting confused. You refer to a field "LOG NO" which is updated by TællerL, are these two fields (in tblA) the same field? and the same for the field ITEM which is updated by TællerITEM. Are these the same field?
I understand "Everytime you open a new record in TblA the field "LOG NO" will increase with 1.( 1-2-3.....) Everytime you open a new record in TblB the field "ITEM" will increase with 1.( 1-2-3-4....)As long as you don´t open a new record in TblA. If you open a new record in TblA, the field "ITEM" should reset to "1". (TællerITEM should be reset)"
but where does TællerL and TællerITEM come into this?
TællerL and Tæller are Tables.(TblTællerL and TblTællerItem. As explained earlier the FrmA (source TblA) have a field LOG NO. Everytime I open FrmA and enter data the LOG NO will increase with 1 ( code in "hændelser" with TblTællerL as source). The FrmB (source TblB)have a field ITEM. Everytime I open FrmB and enter data the ITEM will increase with 1 ( code in "hændelser" with TblTællerITEM as source). As it is now, the TællerL will count op to 9999999 before it resets to 1 the sam e for TællerITEM. What I am after is a piece of code to replace the excisting part of code ( "count until 9999999 before reset to 1") The TællerITEM should "look" at TællerL. If TællerL increase (FrmA open and activated) the TællerITEM should reset to 1.
itmust be becuase its almost the weekend, but I'm finding ithard to understand all of these forms/fields. Is it possible for you to send an example of your dB so i cna see for myself?
Endelig svar. Den oprindelige kode some er indsat i FrmB skal deles i 2 DoCmd sætninger
Oprindelig sætning: DoCmd.SetWarnings False If Tlr = 9999999 Then DoCmd.RunSQL "UPDATE TællerITEMSET Nr=1" Else DoCmd.RunSQL "UPDATE TællerITEM SET Nr=Nr+1" End If DoCmd.SetWarnings True
DoCmd sætning 1: (tællerfunktion) Denne kode skal indsættes i FrmB under ”before insert”. DoCmd.SetWarnings False DoCmd.RunSQL "UPDATE TællerITEM SET Nr=Nr+1" DoCmd.SetWarnings True
DoCmd sætning 2:(Reset funktion) Updateringskoden skal indsættes i FrmA under ”before insert”. DoCmd.SetWarnings False DoCmd.RunSQL "UPDATE TællerITEM SET Nr=1" DoCmd.SetWarnings True
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.