473,503 Members | 2,082 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem in running or open the query

12 New Member
Hi Everybody..

This is my firstime in creating report using microsoft access.
Actually i need to build a report based on a database call Table1.
I only use 2 column of databse to put in my report.

1) State
2) Status

For status, i need to separate it based on value of status;
Eg: 1)Ready
2) Not ready

I had create 2 query,one for ready and one for not ready.
I combine this 2 query into one query called StateStatus to build the report.

When i run or open to view the StateStatus query,the error message occur.I only can view it by design view.

Error:
The query can not be completed either the size of the query result is larger than the maximum size of databse (2GB) or there is not enough temprary storage space on the disk to store the query result.


Is it my step to create query for report is wrong?
How to solve to make the query can run or open.


Thank you.
Jun 30 '08 #1
14 3552
Stewart Ross
2,545 Recognized Expert Moderator Specialist
Hi. It sounds like you have accidentally multiplied your two queries when you tried to join them back to each other. This is known as the Cartesian product of the rows, and happens when you include the tables but neglect to join them on the relevant common field. I'm not sure what you want to do with the two fields you mention - Status and State - but the most obvious thing is to group by the values concerned and count the rows for each state.

You don't need two queries to do this. Simplest approach is to use the Access query editor, add your primary table to the query, use View, Totals to select grouping and totalling, add the state and status fields, then add a copy of the status field, giving it a different name (Count of Status, say) and change its Group By to Count.

-Stewart
Jun 30 '08 #2
nico5038
3,080 Recognized Expert Specialist
It would be easy for us when you would post a sample you need like:
Expand|Select|Wrap|Line Numbers
  1. State Ready NotReady
  2. UK      123       33
  3. DK       22        5
  4. etc...
  5.  
This can be done by a groupby query or a crosstable query.

Nic;o)
Jul 1 '08 #3
akmaRudiliyn
12 New Member
Thank you Stewart Ross Inverness and nico5038 for your help.

Yes, actually i want to have the same structure that had stated by nico5038,
but i dont know how to do.
Actually Status have 3 value.

1)Ready
2)Not Ready
3)Nothing

I already done the query but it is not work. It only show for Status Ready,
but Status Not Ready and Nothing are not showed. Maybe my query is wrong.

My query:

SELECT State, Count(Status) AS Status1
FROM Table1
WHERE (Status='Ready')
GROUP BY State

UNION

SELECT State, Count(Status) AS Status2
FROM Table1
WHERE (Status='Not Ready')
GROUP BY State

UNION

SELECT State, Count(Status) AS Status3
FROM Table1
WHERE (Status='Nothing')
GROUP BY State;

Anyone can help me?
Jul 2 '08 #4
Stewart Ross
2,545 Recognized Expert Moderator Specialist
As Nico said, you can do this as a group by or crosstab query. There is no need for the union-query approach. The group-by version, which shows counts for each Status on separate rows, is:
Expand|Select|Wrap|Line Numbers
  1. SELECT State, Count(Status) AS StatusCount FROM Table1 GROUP BY State, Status;
The Crosstab version, which shows all status values as column headings, is:
Expand|Select|Wrap|Line Numbers
  1. TRANSFORM Count([Status]) As StatusCount
  2. SELECT State From Table1
  3. GROUP BY State
  4. PIVOT Status;
-Stewart
Jul 2 '08 #5
nico5038
3,080 Recognized Expert Specialist
Or the ultimate "GroupBy does it all in one query" solution:

Expand|Select|Wrap|Line Numbers
  1. SELECT State
  2. , Sum(IIF(Status='Ready',1,0)) AS Ready
  3. , Sum(IIF(Status='Not Ready',1,0)) AS NotReady
  4. , Sum(IIF(Status='Nothing',1,0)) AS Nothing
  5. , Sum(IIF(IsNull(Status),1,0)) AS Empty
  6. FROM Table1
  7. GROUP BY State
  8.  
Nic;o)
Jul 2 '08 #6
akmaRudiliyn
12 New Member
Thank you again to Stewart Ross Inverness and nico5038 for help me.

Now my problem is solved. Thank you so much :).I want to ask another question.
Below is my query same as nico5038 give before. I just use it because look simple.

My query:

SELECT Language,
Sum(IIf(State='UK',1,0)) AS State1,
Sum(IIf(State='EGYPT',1,0)) AS State2,
Sum(IIf(State='RUSIA',1,0)) AS State3,
Sum(IIf(State='MEXICO',1,0)) AS State4,
Count([No TG]) As TGAmount,
--abcdefg--
FROM Student
GROUP BY Language;


At --abcdefg-- space,
actually i want to make a query that can count all the value of [No TG] group by State.
how can i combine the query?

(SELECT Count([No TG]) AS (TotalTG) From [Maklumat Pelajar] GROUP BY State)

Once again..anyone can help me? :)
Jul 3 '08 #7
nico5038
3,080 Recognized Expert Specialist
Just switch the Language field by the [No TG] field and see the effect.

Nic;o)
Jul 3 '08 #8
akmaRudiliyn
12 New Member
Thank you all for helping me.

1) I had sort my data in ascending order A-Z,but it is not sort properly. Why it is happen? How to solve it?

Eg:

C
B
A
A,B
A,B,
B


2) I also want to know the right way to filter use Visual Studio .net. Let say i want to filter the column <Blank> and Brunei for State row.

Eg:

State
<Blank>
Brunei
Singapore
Rusia
Jul 7 '08 #9
akmaRudiliyn
12 New Member
Below is my code to filter data. I want to arrange the data by state from north to south. First, Perlis, 2nd Perak and so on until Sabah. But the data is still sort by a-z(ascending) or z-a(descending) order. For example, Johor, Kedah,Kelantan..Terengganu..I dont want this order.

Anyone can check my query below..

SELECT State,
Sum(IIf(Status='Ready',1,0)) AS Ready,
Sum(IIf(Status='Not Ready Aktif',1,0)) AS NotReady,
Sum(IIf(Status='Cancel',1,0)) AS Cancel,
Sum(IIf(Status='Nothing',1,0)) AS Nothing,
Sum(IIf(IsNull(Status),1,0)) AS Empty,
Count(*) AS Total
FROM Table1

WHERE
((State='Perlis'
Or State='Kedah'
Or State='Perak'
Or State='P.Pinang'
Or State='Kuala Lumpur'
Or State='Selangor'
Or State='Melaka'
Or State='N.Sembilan'
Or State='Pahang'
Or State='Terengganu'
Or State='Kelantan'
Or State='Johor'
Or State='Sabah'
Or State='Sarawak'))

GROUP BY Negeri

ORDER BY
((State='Perlis'
Or State='Kedah'
Or State='Perak'
Or State='P.Pinang'
Or State='Kuala Lumpur'
Or State='Selangor'
Or State='Melaka'
Or State='N.Sembilan'
Or State='Pahang'
Or State='Terengganu'
Or State='Kelantan'
Or State='Johor'
Or State='Sabah'
Or State='Sarawak'));

Anyway, this code is not work. It still sort data by ascending or descending, not follow as i arrange. Anyone can help me?Maybe my query is wrong.
Jul 7 '08 #10
Stewart Ross
2,545 Recognized Expert Moderator Specialist
Hi. You should store your states in a separate State table. You can then include a column in that table to store the custom sort order, as a numeric value (an integer or long number). You can then define the sort order you want by setting values in ascending order. For example, Perlis would have sort order 1, Perak 2 and so on. You would subsequently sort on the custom sort order field, not alphabetically on the state name.

You could also include a status field for each state showing whether or not the states are active.

If you store these details in a base table you can do away with the hard-coding in your query. The approach you are taking at present is very difficult to maintain. Consider what happens if you add a new state; at present you have to change your query to accommodate the new state, whereas if you put all relevant details in your state table your query will not have to change at all.

Expand|Select|Wrap|Line Numbers
  1. ...
  2. WHERE 
  3. ((State='Perlis' 
  4. Or State='Kedah' 
  5. Or State='Perak' 
  6. Or State='P.Pinang' 
  7. Or State='Kuala Lumpur' 
  8. Or State='Selangor' 
  9. Or State='Melaka' 
  10. ...
  11.  
-Stewart
Jul 7 '08 #11
akmaRudiliyn
12 New Member
Ok, but actually i cannot modify the structure of my table.
How about if i have column name Race with various of values.
From the value i want to group by it into Foreign, Bumiputera and Non Bumiputera.

Eg:
Foreign
Korean
Japan

Bumiputera
Malay

Non Bumiputera
Chinese
Indian
Jul 9 '08 #12
akmaRudiliyn
12 New Member
Hai..anyone can help me..
I need to make report use database access.
I use sql query that given by friends here.
But i have face 2 problem.

a) How to filter data,to make data in database, either with gap (space) and without gap,as same data.

Eg:
1) Pulau Pinang same data as PulauPinang
2) Pulau Pinang same as P.Pinang
3) __(Gap) Pulau Pinang = Pulau Pinang

b) how to make data is upper case same with lower case
Eg: Pulau Pinang = PULAU PINANG
pulau pinang = PULAU PINANG

i had found this function to make it al uppercase but not work. Mybe i code in wrong way.
--UCASE(c)

Help me pliz..
Aug 6 '08 #13
Stewart Ross
2,545 Recognized Expert Moderator Specialist
HI akma. You really need to post a separate thread for a new question.

UCase is very simple to use and does indeed convert from mixed case to all uppercase. Like any function, if you want to use it in a report without including it in your report's recordsource you will need to place an unbound control on the report, then in the control's controlsource property set it to

=UCase([your field name])

You must make sure that the control is not named the same as the field you are trying to convert to uppercase (or the same as any other field in your report's recordsource) as this will cause an error.

My preference would be to include such computed fields in the underlying query on which the report is based, then the computed field can just be dragged and dropped onto the report in design view as needed.

There is no easy answer to your part (a) question; it is not possible in one operation to cover all possible variations in spelling of place names that might be encountered and replace them with one standard version when you have not designed tables for selection of standard places and place names, as originally recommended to you in answer to your earlier post.

It is possible to remove spaces from a string - the Replace function will do this for you - but if you cannot use UCase at present I suspect you will not be in a position to use Replace either.

If you want to try it as a computed field in a query, you can remove spaces like this:

NewComputedField = Replace([your place name field], " ", "")

-Stewart
Aug 6 '08 #14
akmaRudiliyn
12 New Member
Thank you for your help Stewart.
Aug 8 '08 #15

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

Similar topics

7
2208
by: Christopher Brandsdal | last post by:
Hi! I have a problem running my code on 2000 server and iis5.0. The code runs perfectly on my localhost (xp iis5.1) but when i run it on 2000 server iis5.0 I get this error: ...
5
9518
by: George Copeland | last post by:
This is a request for help fixing a SQL Server 2000/ADO problem on Windows XP. I would appreciate any useful assistance. PROBLEM: SQL Server access on my machine fails as follows: 1. All of...
6
3041
by: wireless | last post by:
I've had my SQL server database running for two years now without a problem. However, just today one of the main tables started returning an error. The table is contained within a database...
4
3810
by: Marcin Zmyslowski | last post by:
Hello everyone! I have the following problem. I`ve opened a Query Analyser and write the statement: -isql -S 'PL6XXXX' -i 'd:\SQL_Server_2000\Raport_WWW.sql' I got the following erorr...
0
1348
by: Javier Fernandez | last post by:
We just migrate out p690 from kernel 32 bits to kernel 64 bits in order to migrate DB2 v7 to DB2 v8 FP3. The only problem without a solution we find out is since we did the change we cannot run...
8
9493
by: Squirrel | last post by:
Hi everyone, I've created a mail merge Word doc. (using Office XP) , the data source is an Access query. Functionality I'm attempting to set up is: User sets a boolean field to true for...
7
6914
by: Salvador | last post by:
Hi, I am using WMI to gather information about different computers (using win2K and win 2K3), checking common classes and also WMI load balance. My application runs every 1 minute and reports...
1
3455
by: Aaron West | last post by:
Try this script to see what queries are taking over a second. To get some real output, you need a long-running query. Here's one (estimated to take over an hour): PRINT GETDATE() select...
9
5742
by: HC | last post by:
Hello, all, I started out thinking my problems were elsewhere but as I have worked through this I have isolated my problem, currently, as a difference between MSDE and SQL Express 2005 (I'll just...
0
7091
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7342
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...
1
6998
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5586
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,...
0
4680
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3171
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3162
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1516
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
741
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.