Using Format and DateAdd

T

Tim Long

Hello, can't understand what I'm doing wrong here.. I'm getting a 'The
expression you entered contains invalid syntax' message.

=DCount("[Client_ID]","tblClients","Format([d_received],"mmyyyy") = #" &
Format(DateAdd("mm",-11,[Forms]![frmReports].[txtYourEndDate]),"mmyyyy") & "#
")

I'm trying to get the total for each of twelve months into text boxes. The
above code, I hoped, would give me the total number of clients received in
the first month of a twelve month period. The text box giving the month
heading (=Format(DateAdd("m",-11,Forms!frmReports.txtYourEndDate),"mmm")
works fine.. Can anyone tell me what I am doing wrong?

Many thanks in advance
 
D

Duane Hookom

I think you only need to change one set of double quotes to single quotes:

=DCount("[Client_ID]","tblClients","Format([d_received],'mmyyyy') = #" &
Format(DateAdd("mm",-11,[Forms]![frmReports].[txtYourEndDate]),"mmyyyy") &
"# ")
 
T

Tim Long

Duane, many thanks, but the single quotes don't work either. Any ideas? It's
quite baffling!

Duane Hookom said:
I think you only need to change one set of double quotes to single quotes:

=DCount("[Client_ID]","tblClients","Format([d_received],'mmyyyy') = #" &
Format(DateAdd("mm",-11,[Forms]![frmReports].[txtYourEndDate]),"mmyyyy") &
"# ")

--
Duane Hookom
Microsoft Access MVP


Tim Long said:
Hello, can't understand what I'm doing wrong here.. I'm getting a 'The
expression you entered contains invalid syntax' message.

=DCount("[Client_ID]","tblClients","Format([d_received],"mmyyyy") = #" &
Format(DateAdd("mm",-11,[Forms]![frmReports].[txtYourEndDate]),"mmyyyy") & "#
")

I'm trying to get the total for each of twelve months into text boxes. The
above code, I hoped, would give me the total number of clients received in
the first month of a twelve month period. The text box giving the month
heading (=Format(DateAdd("m",-11,Forms!frmReports.txtYourEndDate),"mmm")
works fine.. Can anyone tell me what I am doing wrong?

Many thanks in advance
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top