New sequential no required depending on other fields in table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • neelsfer
    Contributor
    • Oct 2010
    • 547

    #1

    New sequential no required depending on other fields in table

    I have a racetiming application. Every cyclist can do up to 10 laps per race. Only do 1 race per date. When i enter the cyclist "raceno" in the field, the current "longtime" is added to the finishtime field. The racename + racedate fields are also filled from the mainform (cyclistF) on this subform called racetimingSF. The "raceno" field is unique for the current racename and racedate, and i use that to link to the riders name etc.
    In the table is also a field called LapNo that should have laps from 1-10 max in per rider raceno, and finish time.
    What i require is ie rider with raceno = 10 finish lap 1, and a 1 is added to LapNo field and his finishtime is added with Now().When rider no 10 finish lap 2, a two is added to the lapNo field together with his finishtime.

    Thus everytime any rider finish a lap, that lapno must be added to the lapno field together with his finish time.
    thus, if each rider's finishtime is later than the previous finishtime now(), then another sequential lapno must be added. How should i do this? pls help
  • jimatqsi
    Moderator Top Contributor
    • Oct 2006
    • 1293

    #2
    Neelsfer,
    Think about what you're saying
    "Thus everytime any rider finish a lap, that lapno must be added to the lapno field together with his finish time. "

    Instead of " that lapno must be added to the lapno field" what you really want is "a 1 should be added to his/her lap number ...each rider's lap count starts at zero and you add one to it each time they finish a lap.

    That seems pretty simple, if you track each rider's laps independently of other riders.

    Does that help?

    Jim

    Comment

    • neelsfer
      Contributor
      • Oct 2010
      • 547

      #3
      As a novice i am not sure how. here are the details

      Mainform = racesetupf
      subform = racetimingsf
      the table name = racetimingT
      FIELDS
      1. racetimingId -- autonumber field
      2. racedate - (only 1x race per day on system and added from mainform with link) --- datefield
      3. racename -- (link master-child field) -- txtfield
      4. finishtime -- (added with now() by entering in form) --- txtfield
      5. LapNo - (can be up to 10 laps per cyclist) --- numberfield
      6. RaceNo - (of the cyclist on his bike, captured up to 10x) -- numberfield
      Basicly, i need a sequential number starting at 1, after every lap per cyclist(raceno) per racedate.

      can something like this work if i get the punctiation right
      Private Sub Form_BeforeInse rt(Cancel As Integer)
      Me.LapNo = Nz(DMax("LapNo" , "Racetiming T", "RacetimingID<> " & RacetimingID & _
      " AND RaceNo=" & RaceNo & " AND [Racedate] = #" & RaceDate & "#"), 0) + 1

      Comment

      • jimatqsi
        Moderator Top Contributor
        • Oct 2006
        • 1293

        #4
        Yes, maybe so. But I'm not sure I would trust the BeforeInsert event to do the job.

        What is causing the record to be creating. Is this happening in real time? Someone is watching a race and pushing a button each time a rider completes a lap (or the automated equivalent of that)?

        If so, the lap number could simply be incremented in the OnClick event of that button. Obviously all the other info for the new record is being set by some event or process, lap number could be part of that already existing process.

        Jim

        Comment

        • Neels Ferreira

          #5
          New sequential no required depending on other fields in table Reply to Thread

          as a rider come through the finish line to complete one of his maybe 2-19 laps, i enter the no on the bike in a subform, press enter which adds the time (now())and the laptime is then calulated in a query by subtracting it from the race starttime for all riders. I need the lapno added when the riders raceno and "finishtime " is added to this table in realtime..

          Comment

          • jimatqsi
            Moderator Top Contributor
            • Oct 2006
            • 1293

            #6
            So it should be fairly trivial to either make an array holding the rider numbers and the number of laps they have finished. Then when they finish another lap you can increment the number of laps for that rider and put that incremented number into their racetimingT record.

            And I think I would change the subform to show a series of buttons, one button for each rider, instead of having to use the keyboard to enter the rider number. So when rider 1 finishes a lap, you have only to click button 1 and so on.

            Jim

            Comment

            Working...