0
votes

Using Access 2003 and want to use DCount to get a count of records in a query that is the recordsource for a subform. I am using an unbound textbox on the subform and get #Error when I use

=DCount("Trans Type","Me.RecordSource",[Void]=False And [Cleared]=False)

as the control source for my unbound control.

I looked at http://access.mvps.org/access/forms/frm0031.htm and it appears that this should work.

Thanks

Jay

1
Use square brackets where you have spaces in column names: "[Trans Type]". Replace "Me.RecordSource" with the name of the query on which your form is based: "[Queryname]". Put your conditions in quotes "[Void]=false and [Cleared]=false" - Lord Peter

1 Answers

1
votes

If RecordSource is the name of a query, something like that that would work, without the quotes and Me:

=DCount("[Trans Type]",[RecordSource],"[Void]=False And [Cleared]=False")

However, it would be best to refer to the query by name. In addition, it may not give the result you want, a subform is usually filtered by the Link Child<->Link Master fields, so if you want a count of the records listed in the subform, it is best to put a control in the form footer and put a count or sum in that.