Oct 11, 2000 #1 philips Programmer Oct 5, 2000 7 GB I have a form and in this I have a subform which is in datasheet view The form and subform are linked by a field How can I check that at least one record has been created in the subform for a record in the form?? [sig][/sig]
I have a form and in this I have a subform which is in datasheet view The form and subform are linked by a field How can I check that at least one record has been created in the subform for a record in the form?? [sig][/sig]
Oct 11, 2000 #2 WP Programmer Nov 30, 1999 463 CH The SQL recordset for the subform will be "SELECT * FROM subformTable WHERE childField='" & txtLinkFieldOnParent & "';" Note I have assumed your link field is alpha-numeric. So you just have to : Dim rsSub as recordset Dim strSQL as String strsql="SELECT * FROM subform WHERE childField='" & txtLinkFieldOnParentForm & "';" Set rsSub=Currentdb.openrecordset(strSQL) Now to check for records : If rsSub.RecordCount=0 then Msgbox "No records" Endif WP [sig]<p>Bill Paton<br><a href=mailto:william.paton@ubsw.com>william.paton@ubsw.com</a><br><a href=http://www.neptune400.co.uk/>http://www.neptune400.co.uk/</a><br> Check out my website ![/sig] Upvote 0 Downvote
The SQL recordset for the subform will be "SELECT * FROM subformTable WHERE childField='" & txtLinkFieldOnParent & "';" Note I have assumed your link field is alpha-numeric. So you just have to : Dim rsSub as recordset Dim strSQL as String strsql="SELECT * FROM subform WHERE childField='" & txtLinkFieldOnParentForm & "';" Set rsSub=Currentdb.openrecordset(strSQL) Now to check for records : If rsSub.RecordCount=0 then Msgbox "No records" Endif WP [sig]<p>Bill Paton<br><a href=mailto:william.paton@ubsw.com>william.paton@ubsw.com</a><br><a href=http://www.neptune400.co.uk/>http://www.neptune400.co.uk/</a><br> Check out my website ![/sig]