A.D.Tejpal
adtp at touchtelindia.net
Fri Jan 23 11:46:20 CST 2004
John,
Kindly put the code given below in the subform's code module and let me know whether it meets your requirement.
Regards,
A.D.Tejpal
--------------
--------------
Code Start
--------------
Option Compare Database
Option Explicit
Private RecNo As Integer ' Global Variable
Private Sub Form_AfterDelConfirm(Status As Integer)
RecNo = RecNo - 1
Me.AllowAdditions = True
End Sub
Private Sub Form_AfterInsert()
RecNo = RecNo + 1
Me.AllowAdditions = False
End Sub
Private Sub Form_Load()
RecNo = DCount("*", Me.RecordSource)
If RecNo > 0 Then
Me.AllowAdditions = False
Else
Me.AllowAdditions = True
End If
End Sub
-------------
Code End
-------------
----- Original Message -----
From: John W. Colby
To: AccessD
Sent: Friday, January 23, 2004 18:13
Subject: [AccessD] subform only allows one record
I need to set up a subform that only allows a single record to be entered.
I have a function in the subform that checks if the
recordsetclone.recordcount >0 and if so sets AllowAdditions = false. This
works fine if any records already exist but if a new record is created, then
if the person does a page down to save the first record, they end up in a
second record. I am firing this function I built from the OnCurrent of the
parent, as well as the OnCurrent of the subform itself. Haven't tried yet
from before update.
Does anyone do this kind of thing? If so how do you accomplish it?
John W. Colby
www.ColbyConsulting.com