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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Urgent: Limiting records in subform

Status
Not open for further replies.
Nov 6, 2002
89
CH
Hi

Is there any code to limit entries of new records to a subform.

If yes, can you help me with the code?

Thank you.

Stefan
 
You could try something like this, in the sub form's current event:

Dim rst As Recordset
Set rst = Me.RecordsetClone
rst.MoveFirst
rst.MoveLast
If rst.AbsolutePosition + 1 >= 10 Then 'set the 10 to max records that you want
gMaxRecordsEntered = true
else
gMaxRecordsEntered = false
End If

--------------------------------------------------
Declare in a global module:

Global gMaxRecordsEntered as boolean

--------------------------------------------------

Behind the button that controls data entry:

If gMaxRecordsEntered = true then
msgbox "etc"
Forms!YourFormName.Form!YourSubFormName.DataEntry = false 'if used
Forms!YourFormName.Form!YourSubFormName.Allowadditions = false
endif

Bill
 
how about in the sql behind the subform... use the keyword
top 10
if the subform is based on a table, then instead base it on some basic sql...

--James
junior1544@jmjpc.net
Life is change. To deny change is to deny life.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top