Group:  Microsoft Access ยป microsoft.public.access.formscoding
Thread: need help with DSUM

Geek News

need help with DSUM
Gator 11/18/2008 4:10:09 PM
I getting invalid syntax with DSUM.

I trying to pull an amount from a atable where criteria is the year in
txtDate AND the account number is in txtAccount.

Both txtDate and txtAccount are on the same form.

Here is my DSUM...

=DSum("Amount","Deposits","[AccountColumn]="[Me!txtAccount] AND
"[DateColumn]="(Year[Me!txtDate])
Re: need help with DSUM
"Douglas J. Steele" <NOSPAM_djsteele[ at ]NOSPAM_gmail.com> 11/18/2008 4:34:22 PM
Your Where condition is incorrect.

From the fact that you've got the equal sign there, I'm assuming that you're
trying to set the ControlSource for a text box. When doing that, you must
leave out the "Me" keyword. As well, the values need to be put outside of
the quotes.

Assuming AccountColumn is a numeric field, try:

=DSum("Amount", "Deposits", "[AccountColumn] = " & txtAccount & " AND
DateColumn = " & Year(txtDate))

If AccountColumn is a text field, try:

=DSum("Amount", "Deposits", "[AccountColumn] = '" & txtAccount & "' AND
DateColumn = " & Year(txtDate))

In case it's not apparent, the difference between the two is that the second
includes single quotes as well. Exagerated for clarity, it's

=DSum("Amount", "Deposits", "[AccountColumn] = ' " & txtAccount & " ' AND
DateColumn = " & Year(txtDate))

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Gator" <Gator[ at ]discussions.microsoft.com> wrote in message
news:4E18E333-EE7E-4AAE-BB1C-0F90B40130B4[ at ]microsoft.com...
[Quoted Text]
>I getting invalid syntax with DSUM.
>
> I trying to pull an amount from a atable where criteria is the year in
> txtDate AND the account number is in txtAccount.
>
> Both txtDate and txtAccount are on the same form.
>
> Here is my DSUM...
>
> =DSum("Amount","Deposits","[AccountColumn]="[Me!txtAccount] AND
> "[DateColumn]="(Year[Me!txtDate])


Re: need help with DSUM
Gator 11/18/2008 5:14:00 PM
Doug
I don't get a error now but the textbox where the DSUM is stays blank. Have
I left something out?
Date is formatted as Date/Time in the table and form control.
Account is format Number.

=DSum("Amount","Deposits","[AccountColumn]= " & [txtAccount] & " AND
[DateColumn] = " & Year([txtDate]))

thanks

"Douglas J. Steele" wrote:

[Quoted Text]
> Your Where condition is incorrect.
>
> From the fact that you've got the equal sign there, I'm assuming that you're
> trying to set the ControlSource for a text box. When doing that, you must
> leave out the "Me" keyword. As well, the values need to be put outside of
> the quotes.
>
> Assuming AccountColumn is a numeric field, try:
>
> =DSum("Amount", "Deposits", "[AccountColumn] = " & txtAccount & " AND
> DateColumn = " & Year(txtDate))
>
> If AccountColumn is a text field, try:
>
> =DSum("Amount", "Deposits", "[AccountColumn] = '" & txtAccount & "' AND
> DateColumn = " & Year(txtDate))
>
> In case it's not apparent, the difference between the two is that the second
> includes single quotes as well. Exagerated for clarity, it's
>
> =DSum("Amount", "Deposits", "[AccountColumn] = ' " & txtAccount & " ' AND
> DateColumn = " & Year(txtDate))
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no e-mails, please!)
>
>
> "Gator" <Gator[ at ]discussions.microsoft.com> wrote in message
> news:4E18E333-EE7E-4AAE-BB1C-0F90B40130B4[ at ]microsoft.com...
> >I getting invalid syntax with DSUM.
> >
> > I trying to pull an amount from a atable where criteria is the year in
> > txtDate AND the account number is in txtAccount.
> >
> > Both txtDate and txtAccount are on the same form.
> >
> > Here is my DSUM...
> >
> > =DSum("Amount","Deposits","[AccountColumn]="[Me!txtAccount] AND
> > "[DateColumn]="(Year[Me!txtDate])
>
>
>
Re: need help with DSUM
Gator 11/18/2008 5:29:01 PM
I got it...I needed the Year([DateColumn]).......thanks

"Douglas J. Steele" wrote:

[Quoted Text]
> Your Where condition is incorrect.
>
> From the fact that you've got the equal sign there, I'm assuming that you're
> trying to set the ControlSource for a text box. When doing that, you must
> leave out the "Me" keyword. As well, the values need to be put outside of
> the quotes.
>
> Assuming AccountColumn is a numeric field, try:
>
> =DSum("Amount", "Deposits", "[AccountColumn] = " & txtAccount & " AND
> DateColumn = " & Year(txtDate))
>
> If AccountColumn is a text field, try:
>
> =DSum("Amount", "Deposits", "[AccountColumn] = '" & txtAccount & "' AND
> DateColumn = " & Year(txtDate))
>
> In case it's not apparent, the difference between the two is that the second
> includes single quotes as well. Exagerated for clarity, it's
>
> =DSum("Amount", "Deposits", "[AccountColumn] = ' " & txtAccount & " ' AND
> DateColumn = " & Year(txtDate))
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no e-mails, please!)
>
>
> "Gator" <Gator[ at ]discussions.microsoft.com> wrote in message
> news:4E18E333-EE7E-4AAE-BB1C-0F90B40130B4[ at ]microsoft.com...
> >I getting invalid syntax with DSUM.
> >
> > I trying to pull an amount from a atable where criteria is the year in
> > txtDate AND the account number is in txtAccount.
> >
> > Both txtDate and txtAccount are on the same form.
> >
> > Here is my DSUM...
> >
> > =DSum("Amount","Deposits","[AccountColumn]="[Me!txtAccount] AND
> > "[DateColumn]="(Year[Me!txtDate])
>
>
>

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net