Nov 30 2003, 03:40 PM
I am having problems in using dcount to count records with the same value as the current record in my form. I have attached my database. Here is what I have tried so far (and the results):
correctly counts #in Req_Rev_PP that have NumCode=”002”
correctly counts #in Req_Rev_PP that have SecCode=”CP”
=DCount("[NumCode]","Req_Rev_PP","[NumCode]='“&[Forms]![Pol_Proc_Info]![NumCode] & ” '")
does not correctly count #in Req_Rev_PP that has same SecCode as current record in Pol_Proc_Info (returns 0)
Ultimately I want to count records in Req_Rev_PP that have the same NumCode AND the same SecCode as current record in Pol_Proc_Info
Dec 1 2003, 06:52 AM
Try this, assuming both numcode and seccode are text fields:
=DCount("[NumCode]","Req_Rev_PP","[NumCode]='" & me.[numcode] & "' and [SecCode]='" & me.[secCode] & "'")
Dec 2 2003, 12:38 PM
Using your code I keep get this: #Name?
I tried using similar code where I only use either NumCode or SecCode but then I get a count of 0 for every record.
Both NumCode and SecCode are text fields. However, in the "policies" table SecCode is a combo box but is just a text field in "requests". Does this matter? Should I make them combo boxes in both tables? NumCode is just a regular text field in both tables (and I can't get this to work even if I'm just trying to match on NumCode).
I know this is not supposed to be so difficult and figure I've just set something up wrong.
Dec 2 2003, 01:26 PM
Try this..I have a message box that pops up in the On Current event that counts the recs for you. I changed a bit of the data in the table where you're counting recs just to make sure it counts correctly.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here