Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

number of records

Status
Not open for further replies.

Greg553

MIS
Jul 6, 2009
60
US
How do you limit the number of records that can be entered .
i'm looking to have a limit on records in the demo program so i can have clients review the program while not be able to enter more than 5 or so records.
thanks
greg
 
You could do something crude like disabling the Add button when there are more than 5 buttons:
Code:
  Dim gdbs As DAO.Database
  Dim rst As DAO.Recordset
  Set gdbs = CurrentDb()
  Set rst = gdbs.OpenRecordset("Test")
  If rst.RecordCount() > 5 Then
    MsgBox("Sorry, this is the demo version.")
    prevButton.SetFocus
    addButton.Enabled = False
  End If


Geoff Franklin
 
How are ya alvechurchdata . . .

In the forms [blue]BeforeUpdate[/blue] event I'd have:
Code:
[blue]   Dim DL As String
   
   DL = vbNewLine & vbNewLine
   
   If Me.Recordset.RecordCount > 4 Then
      MsgBox "This is the DEMO!" & DL & _
             "No more records can be added!", _
             vbInformation + vbOKOnly, _
             "Demo Record Limit Reached!"
      Me.Undo
      Me.Undo
   End If[/blue]
This will thwart any attempt to append more than 5 records.

[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Code:
Me.Recordset.RecordCount

Why do I always miss the simple way?

My only excuse is that I was already using DAO and had rst available as a variable. If Greg553 is starting from scratch then yours is the better solution.

Geoff Franklin
 
alvechurchdata said:
[blue]Why do I always miss the simple way?[/blue]
You havn't used it any where near as much as DAO Recordsets! Just remember that which is returned by a forms [blue]Record Source[/blue] [purple]is a Recordset![/purple] [thumbsup2]

As an example of moving to a record, instead of building and finding to finally set a bookmark, you could:
Code:
[blue]   Me.Recordset.FindFirst "ID = " & Me!ID[/blue]
Also, there's nothing wrong with your code ... it will work! I don't understand the excuse [surprise]

In any case ... [blue]you take care ... Ya Hear[/blue] [thumbsup2]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Woops! [surprise]

A line of code is missing:
Code:
[blue]   Dim DL As String
   
   DL = vbNewLine & vbNewLine
   
   If Me.Recordset.RecordCount > 4 Then
      MsgBox "This is the DEMO!" & DL & _
             "No more records can be added!", _
             vbInformation + vbOKOnly, _
             "Demo Record Limit Reached!"
      Me.Undo
      Me.Undo
      [purple][b]Cancel = True[/b][/purple]
   End If[/blue]
Sorry about that ...

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Thanks for the reply's and help. i had a little trouble with the code the missing part now helps. Still learning all this stuff
 
One question. When i enter the information in the form, name, height weight etc it shows up double in the sub form.
How can i fix this
 
Greg553 . . .

Start a new thread for this new issue. This way you'll be exposed to the entire forum!

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top