how to limit number of records displayed in subform in access 2007

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

    #1

    how to limit number of records displayed in subform in access 2007

    i want to limit the capturing in a subform to the first 10 records. Pls help

    mainform = racesetupf (table name =racesetup)
    fields = racesetupid(aut ono)
    racename(txt); racedate(short)

    Subform = RaceTimingSF
    Table = RacetimingT
    RacetimingId (autonumber)
    Finishseq (number)
    RaceNo (number)
    Racedate (date)
    Racename (txt)

    The finishseq field adds a sequential number every time a raceno is captured.
    What i need is an statement such as "If the value of finishseq =10, then close access. The code in the "beforeinse rt" of the subform is
    FinishSeq = Nz(DMax("Finish Seq", "Racetiming T")) + 1

    pls help
  • gnawoncents
    New Member
    • May 2010
    • 214

    #2
    I think I understand what you're trying to do. See if the code below works and let me know.

    Code:
    Private Sub Form_BeforeInsert(Cancel As Integer)
    
    FinishSeq = Nz(DMax("FinishSeq", "RacetimingT")) + 1
    
    If FinishSeq = 10 then
      cancel = true
    End If
    
    End Sub

    Comment

    • neelsfer
      Contributor
      • Oct 2010
      • 547

      #3
      thx a million

      Comment

      • neelsfer
        Contributor
        • Oct 2010
        • 547

        #4
        just before i got your message, i stumbled across this code that works and is very similar

        If Me.Finishseq <10 Then
        MsgBox "Maximum records already saved. No more may be added.", vbOKOnly
        Cancel = True
        Me.Undo
        End If

        Comment

        Working...