One More Time

  • Thread starter Thread starter Dan B
  • Start date Start date
D

Dan B

Hi Again,

There is a scroll bar at the bottom of my MS Access
form. It allows me to scroll forward and backward
through the records (rows) attached to the form. I DON'T
care what it's called, I DON'T want to remove it and I
DON'T want to go out someplace and try to find a question
I asked two months ago.

The scroll bar allows the user to add a record. I want
to keep the user from using that scroll bar to add a new
record if the record maximum has been exceeded. I
determine the current number of records by using DCOUNT
on the table. What event controls the add record from
the scroll bar? All I want to do is get in there, count
the records and if the maximum has been exceeded, don't
add the new record.

Thanks Again,
Dan
 
Dan

To prevent new records from being added, set the form's .AllowAdditions
property to FALSE. I think this is the one piece of the pie you didn't
receive before.

HTH

--
Rob

FMS Professional Solutions Group
http://www.fmsinc.com/consulting

Software Tools for .NET, SQL Server, Visual Basic & Access
http://www.fmsinc.com

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 
Hi Again,

There is a scroll bar at the bottom of my MS Access
form. It allows me to scroll forward and backward
through the records (rows) attached to the form. I DON'T
care what it's called, I DON'T want to remove it and I
DON'T want to go out someplace and try to find a question
I asked two months ago.

The scroll bar allows the user to add a record. I want
to keep the user from using that scroll bar to add a new
record if the record maximum has been exceeded. I
determine the current number of records by using DCOUNT
on the table. What event controls the add record from
the scroll bar? All I want to do is get in there, count
the records and if the maximum has been exceeded, don't
add the new record.

Thanks Again,
Dan

What version of Access do you use? For Access 2000 onward, you could
do it like this

Private Sub Form_Current()

Const MaxRecs As Long = 100

Me.AllowAdditions = DCount("*", "YourTable") < MaxRecs

End Sub

HTH
Matthias Kläy

P.S. the "Scrollbar" is called the "Navigation Buttons" :-)
 
The scroll bar allows the user to add a record. I want
to keep the user from using that scroll bar to add a new
record if the record maximum has been exceeded. I
determine the current number of records by using DCOUNT
on the table. What event controls the add record from
the scroll bar?

The Form's BeforeInsert event, which is cancellable:

Private Sub Form_BeforeInsert(Cancel as Integer)
If DCount(...) > {some number} Then
Msgbox "Too many!", vbOkOnly
Cancel = True
End If
End Sub
 
Back
Top