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

Checking for at leat one entry in a subform

Status
Not open for further replies.

philips

Programmer
Oct 5, 2000
7
0
0
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]
 
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= Check out my website ![/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top