limiting inputs data record for patient in same month

raphael99

Registered User.
Local time
Today, 11:22
Joined
Apr 6, 2015
Messages
126
How to limit input data on the same month for each patient? The field is a data/text box on a subform

I found this code on Form Current Event!:
Code:
[COLOR=#E56717][B]Private[/B][/COLOR] [COLOR=#E56717][B]Sub[/B][/COLOR] Form_Current()     [COLOR=#151B8D][B]Dim[/B][/COLOR] intMaxNumRecs [COLOR=#151B8D][B]as[/B][/COLOR] [COLOR=#F660AB][B]Integer[/B][/COLOR]       intMaxNumRecs = 5 [COLOR=#008000]'Max Number of Records to Allow [/COLOR]     [COLOR=#8D38C9][B]If[/B][/COLOR] Me.NewRecord [COLOR=#8D38C9][B]Then[/B][/COLOR]         [COLOR=#8D38C9][B]With[/B][/COLOR] Me.RecordsetClone             [COLOR=#8D38C9][B]If[/B][/COLOR] .RecordCount > 0 [COLOR=#8D38C9][B]Then[/B][/COLOR]                 .MoveLast:  .MoveFirst                 [COLOR=#8D38C9][B]If[/B][/COLOR] .RecordCount >=  intMaxNumRecs [COLOR=#8D38C9][B]Then[/B][/COLOR]                     MsgBox [COLOR=#800000]"Can't add more than "[/COLOR] &  intMaxNumRecs & [COLOR=#800000]" records in the demo database!"[/COLOR]                     .MoveLast                     Me.Bookmark = .Bookmark                 [COLOR=#8D38C9][B]End[/B][/COLOR] [COLOR=#8D38C9][B]If[/B][/COLOR]             [COLOR=#8D38C9][B]End[/B][/COLOR] [COLOR=#8D38C9][B]If[/B][/COLOR]         [COLOR=#8D38C9][B]End[/B][/COLOR] [COLOR=#8D38C9][B]With[/B][/COLOR]     [COLOR=#8D38C9][B]End[/B][/COLOR] [COLOR=#8D38C9][B]If[/B][/COLOR] [COLOR=#8D38C9][B]End[/B][/COLOR] [COLOR=#E56717][B]Sub[/B][/COLOR]

But I want a monthly limit
 
Last edited:
I reformatted your code for readability
Code:
Private Sub Form_Current() 
    Dim intMaxNumRecs as Integer 
	intMaxNumRecs = 5 'Max Number of Records to Allow     
	If Me.NewRecord Then        
		With Me.RecordsetClone             
			If .RecordCount > 0 Then                
			.MoveLast:  
			.MoveFirst
				If .RecordCount >=  intMaxNumRecs Then                    
				MsgBox "Can't add more than " &  intMaxNumRecs & " records in the demo database!"                     
				.MoveLast                    
				Me.Bookmark = .Bookmark                
				End If             
			End If         
		End With    
	End If
	End Sub
 

Users who are viewing this thread

Back
Top Bottom