I'm trying to use the DCount function as a control source on a form. In the criteria portion I want to compare one of the date fields in the records to a date field that is on the form. I've tried some experiments and I can get it to work if I compare it to literal dates as follows:
=DCount("[Region]","AccessPermits","[ReceiveDate]> #01/01/2008# and [ReceiveDate]< #01/01/2009#"),
and I can get it to work when I compare it to another field in the record as follows:
=DCount("[Region]","AccessPermits","[ReceiveDate]> #01/01/2008# and [ReceiveDate]< [DateTransmit]"),
however when I try to compare it to a field on the form as follows:
=DCount("[Region]","AccessPermits","[ReceiveDate]> #01/01/2008# and [ReceiveDate]<= #" & [Forms]![Test]![StartDate] & "#"),
I get a syntax error.
I can use the exact syntax in VB and it's ok, so I could populate the field in a more roundabout way if I must, but I would prefer to be able to do it right in the control source.
=DCount("[Region]","AccessPermits","[ReceiveDate]> #01/01/2008# and [ReceiveDate]< #01/01/2009#"),
and I can get it to work when I compare it to another field in the record as follows:
=DCount("[Region]","AccessPermits","[ReceiveDate]> #01/01/2008# and [ReceiveDate]< [DateTransmit]"),
however when I try to compare it to a field on the form as follows:
=DCount("[Region]","AccessPermits","[ReceiveDate]> #01/01/2008# and [ReceiveDate]<= #" & [Forms]![Test]![StartDate] & "#"),
I get a syntax error.
I can use the exact syntax in VB and it's ok, so I could populate the field in a more roundabout way if I must, but I would prefer to be able to do it right in the control source.