counting records on another form

CALV

Registered User.
Local time
Today, 23:14
Joined
Apr 25, 2001
Messages
74
Hi all,

Have a main form with a subform, basically the suer selects parts used on the main form, these are then transferred to the subform whos value is stored in table "parts_used", however as the "accept" button is clicked on the main form, I need to count the parts_used and enter the total in a text box, I have no problem counting records normally- but have never needed to count them on a subform, can anyone help?
TIA
 
The only difference is that you need to make sure you are referring to the subform correctly - check out the Microsoft Knowledge Base article 113352.
 
Thanks for the reply, I know how to access PARTS of a subform, i.e.forms![form name]![field] etc, but I cant get it to do anything else, i.e. count the number of records, im sure its something simple but theres that many commands lol.
 
Okay - try this - I placed this under a command button to test it, but you can place it under the On Current property of the form:

Dim dbs As Database
Dim rst As Recordset

Set dbs = CurrentDb()
Set rst = Forms![YourMainForm]![YourSubForm].Form.RecordsetClone

Me.YourCountField = rst.RecordCount

HTH
 
Hi,

Thanks for the help, only it doesnt quite work :( not sure where Im going wrong, I get an error on this line

Set rst = Forms![parts_main]![parts_sub].Form.RecordsetClone

My main form is parts_main and the subfom is parts_sub (original!!)

I get an error saying it cant find the field "parts_sub"
 
be sure you are referring to the subform correctly. IS the name of the subform [parts sub] or [parts sub(original!!]?

Also enclose the form names in brackets just to be sure.
 

Users who are viewing this thread

Back
Top Bottom