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

How do i check to see if any records in a subform

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
Hello
I have a Form "Parts" that contains a combo box. The form also contains a Subform "PartsSubform".
Im trying to get it so that a message box appears in the afterupdate event for the combobox. The catch is that i only want it to appear if there are records in the subform.
Im just wondering if i could use an "if statement" to achieve this. If I can does anyone know how i would phrase it.
I believe that i could use DAO to access the the table relating to the subform. Then check if any records exist according to the criteria of the mainform. However if i can just use an "if" statement it would make it much easier.
Thanks for any advice given.
 
An easy way is to add a calculated field to the form footer of the sub-form with the control source as "=count([keysubfieldname])". You can then check whether this is >0 with an If statement. If you add =nz([fieldname])>0 to your if statement this will convert null to 0 as the two are not the same.
I usually add a calculated field on the main form to display this total, with the control source set to "=[countfieldonsubform]" (use the build button [...] to navigate to the control on the sub form so you get the correct syntax inserted automatically).
I am not sure how you wish to use the combobox so I'll leave that to someone else!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top