View Single Post
  #11  
Old March 25th, 2010, 03:22 PM posted to microsoft.public.access.forms
RonaldoOneNil
external usenet poster
 
Posts: 345
Default #ERROR in textbox

Clearly there is a problem because he can't get it to work.
I have just recreated it in a test DB. I got it to work by having single
quotes on the first Format statement and double quotes on the second. My
customer No and Posting Date Period are both text but the Posting Date period
is stored as a dd/mm/yyyy
The folllowing then worked

=DSum("[Amount]", "July 09 - On Billings and Adjustments Data Query",
"[Customer No] = '" & Me.cboCustomerNumber & "' And Format([Posting Date
Period],'yyyymm') = '" & Format(Me.cboPostingDate, "yyyymm") & "'")

"BruceM via AccessMonster.com" wrote:

There is no problem with the quotes in the format statement. I tested before
I posted the suggestion, which was confirmed by an MVP (Douglas Steele?) who
posted in an earlier thread on this topic. Your suggestion looks for an
exact date match, not a month/year match as the OP wants. If an exact date
match is needed it would be best to use date delimiters (#), but again that
is not what is requested here.

The OP stated (although with question marks in the statement, so I'm not
quite sure what to make of that) that Posting Date Period is a text field.
If so, it should be changed to a Date/Time field. The Format function seems
to be able to apply date/time formatting to a text string that "looks" like a
date.

To the OP, be sure the exact field names, not any table field captions you
may have used, are included in the DSum expression. That is typically the
source of the #Name error.

Also, please post some sample data (from just a few records) of the actual
values in Posting Date Period.


RonaldoOneNil wrote:
You need them around each argument in the DSum statement and it is because of
this that it errors when you have them in your Format statement. It needs to
be something like this

=DSum("[Amount]", "[July 09 - On Billings and Adjustments Data Query]",
"[Customer No] = '" & [cboCustomerNumber] & "' AND [Posting Date Period] = '"
& cboPostingDate & "'")

I Take the quotes out like this

[quoted text clipped - 38 lines]

Thanks in advanced


--
Message posted via http://www.accessmonster.com

.