Link to home
Start Free TrialLog in
Avatar of cansevin
cansevin

asked on

Syntax for querry

I am trying to do a sumif formula that isn't working. If the value of the Office is "949 S. Orange County" I want it to sum the data. I am using the below syntax. When I run the querry it asks me to Enter Parameter Value for Office.Customer Info Table. If I type in "949 S. Orange County" then it works properly I'd like to to look for it without asking me to enter it. Any ideas?

Sum(IIf([Office].[Customer Info Table]="949 S. Orange County",[ExtendedPrice],0)) AS [949 Office]
Avatar of cansevin
cansevin

ASKER

It actually doesn't work when I type the text in. Not sure what's going on! Please help!
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
What is the actual name of the Table (or Query) and the Field in the Table (or Query) ?

Maybe you should try 909 W. San Bernardino County :-)
The table name is Customer Info Table
The Field name is Office

In that field there are values that read "949 S. Orange County" I want it to sum those values. Thanks!
Are you certain that the field [Customer Info Table] exists in the Office table?  Be sure to verify the field is spelled the same way.

Ron
ASKER CERTIFIED SOLUTION
Avatar of IrogSinta
IrogSinta
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yes... it is there. Here is the entire syntax:
SELECT Format([Bookings.DateRecorded],"ww") AS Week, Sum(IIf(Year([Bookings.DateRecorded])=2014,[ExtendedPrice],0)) AS [2014 Rev], Sum([Booking Details Extended].ExtendedPrice) AS SumOfExtendedPrice, [Customer Info Table].Office, Sum(IIf([Office].[Customer Info Table]="949 S. Orange County",[ExtendedPrice],0)) AS [949 Office]
FROM [Customer Info Table] INNER JOIN ([Booking Details Extended] INNER JOIN Bookings ON [Booking Details Extended].BookNumber = Bookings.BookNumber) ON ([Booking Details Extended].CustomerID = [Customer Info Table].CustomerID) AND ([Customer Info Table].CustomerID = Bookings.CustomerID)
WHERE (((Bookings.DateRecorded) Between #1/1/2014# And #12/31/2014#))
GROUP BY Format([Bookings.DateRecorded],"ww"), [Customer Info Table].Office;
Thanks! Sorry MX... but good to see you are local! You do a great job on this!