473,396 Members | 1,755 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Condition in report? Access 2007

Dear all
Am trying to put the following query in a report
Expand|Select|Wrap|Line Numbers
  1. SELECT color, sum(qty*u.p) as total 
  2. FROM table 
  3. WHERE flag = "00" 
  4. GROUP BY color
  5.  
couldnt set the fillter
i tried :
Expand|Select|Wrap|Line Numbers
  1. docmd.openreport "rpt", acViewPreview, wherecondition:= "flag = 00 group by color" 
i got missing operator errot, but have no idea what operator.

rpt is created in design on table table which is the one in the above query

Also i couldt find a wasy to place a textbox in rpt in order to hold the value SUM(qty*u.P)

Any ideass ???
regards,
Mar 28 '11 #1
7 3439
TheSmileyCoder
2,322 Expert Mod 2GB
Your WhereCondition includes your group by clause. Your where statement is:
Expand|Select|Wrap|Line Numbers
  1. WHERE flag="00"
and is seperate from your GROUP by clause:
Expand|Select|Wrap|Line Numbers
  1. GROUP BY color
If flag is a string type field, which it seems to be from your example, you need to include that part in your where condition by enclosing the 00 in single quotes:
Expand|Select|Wrap|Line Numbers
  1. docmd.openreport "rpt", acViewPreview, wherecondition:= "flag = '00'" 
As for the textbox, place a textbox in the report, and set its controlsource to Total since thats what you have specified it should be called in your query (see the sum(qty*u.p) as total )
Mar 28 '11 #2
Very thanks for your fast reply man, but how can i group the result ??

Also , how can the textbox knows the total even if i assign the controlsource as total, since am not bounding it to that query (the query is an example to show the result i need in the report only), am bounding the report to the table table and am filtering the records upon my where condition only , then i need to get the totals of the filtered records??


I tried ur statement:
it generated the color without grouping where the condition is true
and it calculated the SUM(qty*u.p) on the whole table that has the condition true, and assign that sum to each record
Which means am having unique sum for all records, and records are not distinct or grouped .
Mar 28 '11 #3
TheSmileyCoder
2,322 Expert Mod 2GB
With the report open in design view, you can specify a group by. I dont know exactly where this setting is in Ac2007, sorry. Once you have found it, you can also specify that each group should have a group footer. In the group footer you should be able to add a textbox with controlsource:=sum(qty*u.p)
Mar 28 '11 #4
ill check it , then be back with a post.
Mar 28 '11 #5
Hello thesmileycoder

i edited the filter by adding the '' , worked fine.
but when i tried to pass the value in a string like:
Expand|Select|Wrap|Line Numbers
  1. docmd.openreport "rpt", acViewPreview, wherecondition:= "flag = ' " & strvalue & " ' AND other = ' " & strvalue2 & " ' " 
Where other is another colomn criteria The report opens but with no records even when i switch to design mode after i run the report, am checking the Filter property, and it says
flag='00' AND other = 'vx' but as if its not accepting the values since no records showing.

What am i doing wrong ???

Regarding the bound issue, switch to layout mode, click on Group & Sort under Grouping and totals a new bar will show at the bottom of the report, click on Add a group, and select the feild u want to group with, very easy :)
Mar 29 '11 #6
TheSmileyCoder
2,322 Expert Mod 2GB
Just to make sure, if you open the report without adding the filter, you DO see your records, right?

Are any of the fields in your recordset lookup columns made with the lookup wizard? (which I recommend against btw)

Other then that I dont have any good suggestions, try posting your reports recordsource SQL.
Mar 29 '11 #7
Well , it seem that the filter wont work if you pass string values , rather than you type the value ie: passing str1 of value 00 wont work
while typing-in the value '00' in the filter property works fine.
Since i created another feild of type number, and i passed multi values(integer values) to the filter and then yoopppiiiiiii , it worked fine :)

but i still am not sure/ or decide if passing string variable wont work, need a little deeper diggggiiinnn .

Numbers worked fine.
Thanks for your help SmileyC. really appriciate.
Mar 29 '11 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Wayne | last post by:
I've been having a click around Access 2007 this afternoon and have discovered some things that range from annoying to alarming. My Access 2003 menu bars, which I, like many others, use...
4
by: lupo666 | last post by:
Hi everybody, this time I have three problems driving me nuts :-((( (1) I have a report with 20 or so Yes/No "squares". Is there a way to either hide/show the "square" or change the yes/no...
4
by: syversda | last post by:
I have a report that runs a bunch of code to populate variables and then those variables are used as the control source in my report fields. for example var1 gets # of records in a table I...
5
by: LadyIlsebet | last post by:
I'm not a fantastic Access developer, but I'm trying to help get Inventory and whatnot organized at work. They are used to 5 year budget plans that list out exactly what has to be purchased what...
9
by: prakashwadhwani | last post by:
Hi !! I'm about to develop a new project for a client. Should I go about it in Access 2003 or 2007 ? Purchasing it either for me or for my client is not a major consideration here ... what I'd...
10
by: Snoopy33 | last post by:
I have a DB that I developed on access XP (2002) and deployed over a year ago. No one has had problems printing any of the reports within the DB until we started loading 2007 on new computers. ...
5
by: Tony | last post by:
I am continuing to develop an Access 2007 application which was originally converted from Access 2003. In Access 2003 I was able to disable the Access Close button in the top righthand corner of...
4
by: Tennotrumps | last post by:
I am trying to export a report to excel but the "excel" option is greyed out. I can export the query the report is based on, but not the report. However, if I open the database on another PC I...
2
by: ghiey | last post by:
hi to all, i have searched for a solution regarding exporting access 2007 reports to excel file. i have converted to access 2007 my database from access 2003. i guess microsoft omitted the ease...
5
by: Scorp Scorp | last post by:
Dear All, I joined newly to Bytes :) Am stuck in the following issue like a week, and couldent find proper fix :( I ll try to breif: I have a recordset, of record count over 4000 records....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.