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

DCount Syntax Problem when used as a control source

Status
Not open for further replies.

bhujanga

Programmer
Oct 18, 2007
181
US
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.
 
Try change
[Forms]![Test]![StartDate]

to

format([Forms]![Test]![StartDate], "mm/dd/yyyy")
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top