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

DCount on subForms

Status
Not open for further replies.

jamespeters01

IS-IT--Management
Apr 3, 2001
75
GB
Hi all,

I am trying to count the number of records in my subform which relate to the main form.

I have so far

=DCount("[SAMPLE_ID]","sample_table")

This works to an extent that it counts all the records within my sample_table. What I'd really like is it to count the number of records in the subform that refer the same field (ENQ NUMBER) in the main table.
Have tried a few different things, but with no success.

Any ideas ??


Thanks
 
Hi!

Try this:

=DCount("[SAMPLE_ID]","sample_table", "[ENQ NUMBER] = " & Forms!YourMainForm!txtEnqNumber)

You will need to use the names of your form and text box. I this code I have assumed the enq number is a number and not text. If this isn't true let me know.

hth


Jeff Bridgham
bridgham@purdue.edu
 
Thank you Jeff, that worked great, but I've just realised I need it slightly different still....doh !

I need the first record on the subform to say "1", then the next record to say "2" and so on. It now just says the Dcount figure. Whoops, didn't think of that !

 
why not use a me.recordcount on the subform?


rollie e
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top