Hello everybody,
I am currently writing a cross-tab query using the following details:
Level Allocated
tbl Contracts
Group By
Row Heading
LevelID
tbl Position Details
Group By
Column Heading
ContractID
tbl Contracts
Count
Value
The table structure is as follows:
tbl Contracts tbl Positions
------------- -------------
ContractID*
PositionID -------PositionID*
Level Allocated LevelID
Other fields... Other fields...
Where * denotes Primary Key and ----- denotes a Foreign Key Link.
A position has a levelID between 1 to 8.
A position with a contract can have Level Allocated from 1 to 8, but it
is not always necessary.
<Question 1>
At the moment, the cross-tab query shows the count results with all the
positions that are not Level Allocated as well.
But I only want to view the count of positions with contracts
(ContractID) that have Level Allocated. I basically want to get rid of
the second line in the table below. Is this possible?
<Question 2>
I also want the blank count fields to show with 0. Is this possible?
Here is the results table as shown:
Level Allocated | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| | 2 | | 4 | 3 | 10| 6 | 12|
2 | 1 | | | | | | | |
4 | | 1 | 1 | | 1 | | | |
6 | | | | 2 | 4 | | | |
7 | | 2 | | | 1 | 2 | | |
8 | | 2 | | | 1 | | 2 | |
I've been working on these issues for hours on end for two days now,
maybe I'm thinking TOO hard! Any help would be appreciated. Thanks!
Regards,
Bernard. 8 1157
On 12 Jul 2005 23:45:29 -0700, em**********@gm ail.com wrote:
<snip> <Question 2> I also want the blank count fields to show with 0. Is this possible?
Hi
Use Nz(xxx,0) rather than xxx as the field to show.
In code you can call Nz with only one argument and it defaults to 0 as
the second, but not in SQL as I found out the hard way.
David
On 13 Jul 2005 02:55:01 -0500, not@here (David Schofield) wrote: On 12 Jul 2005 23:45:29 -0700, em**********@gm ail.com wrote:
<snip> <Question 1>
..
Hi
Not sure I fullly understand Question 1 but I thibk you want something
like
TRANSFORM Count(nz([ContractId],0))
SELECT tblContracts.Le velallocated
FROM tblPositions INNER JOIN tblContracts ON tblPositions.Po sitionId =
tblContracts.Po sitionId
WHERE tblContracts.Le velallocated<>0
GROUP BY tblContracts.Le velallocated
PIVOT tblPositions.Le velId;
This assumed that Levelallocated is set to default to zero, otherwise
use
WHERE isNull(tblContr acts.Levelalloc ated)
David
Bernard:
To have zeroes instead of blanks, change ContractID to
NZ(Count([ContractID]),0) and change Count to Expression. Then, in the
criteria line of Level Allocated, type > 0.
Rog
(sorry if this is a double post, my first reply did not seem to go
through)
Bernard,
To have zeroes instead of blanks, change ContractID to
NZ(Count([ContractID]),0) and change Count to Expression. Then to get
rid of the blank (which is now 0), type >0 in the criteria of Level
Allocated.
Rog
Bernard,
I hope I understood your questions properly.
Q1 : put an 'is not null' criteria (no quotes) in the [level
allocationed] field to get rid of the blank line
Q2 : nz(count(Contra ctID),0) . . . then put 'Expression' in the total
Line
HTH
Pachydermitis
Q1
filter out the stuff you don't want with a select query, and base the
crosstab on that select query.
Q2
one way - base a query on this one and use NZ to convert the nulls to
zeroes.
1. Try specifying "Is Not Null" in the criteria row for the [Level
Allocated] column.
2. Instead of...
ContractID
tbl Contracts
Count
Value
....try...
Expr1: IIf(IsNull([Contracts]![ContractID]),0,1)
Sum
Value
Hi guys!
Thanks for all your help. It works wonders. I had no idea about the NZ
function.
Cheers!
Bernard This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Louis |
last post by:
Is there a switch or a setting in Access so that a group by query
doesn't return a field name SumOf(original field name)? Especially
when you chain multiple queries together you'd get SumOfSumOfSumOf....
Anyone know? TIA.
|
by: D Denholm |
last post by:
I am a Access newbie... Hopefully somebody can help me figure this
out.
I have a database that looks like:
Asset Economic Minimum
----- ----------------
10555 320
10555 320
10555 320
|
by: Megan |
last post by:
Hi everybody-
I have 2 tables, Hearings and Rulings. Both have primary keys called,
CaseID, that are autonumbers. I don't want both tables to have the
same autonumber. For example, if Hearings has 55, then I want Rulings
to have a number greater than 55. Two or more Hearings may be entered
before a Ruling is entered. For example, Hearings with CaseIDs= 55,
56, and 57 may be entered before a Ruling or vice versa. There is no
definite...
|
by: Norbert Lieckfeldt |
last post by:
I am setting up a database for a friend who's an Optician,
using MS Access 2002. All seems to be working well, but I have hit a
snag.
There's a calculated field both in a form and a query which calculates
the date for the next appointment from a date field and the number of
months to the next appointment. That works fine.
For reminder letters, I need to have a query which allows me to select
a subsection of dates between dd/mm/yyyy...
|
by: temp |
last post by:
Hi all,
I know this is easy for you guys but I am not a VB developer. My boss
just wanted me to generate a mapping of all the queries in our Access
DB. So I managed to create some subroutines to get the queries. I just
need now to parse the SQL string and get the field names. Then import
it to Excel.
Input:
Select field1, field2 FROM Table1
| |
by: jjturon |
last post by:
Can anyone help me??
I am trying to pass a Select Query variable to a table using Dlookup
and return the value to same select query but to another field.
Ex.
SalesManID SalesManName
AT Alan Time
|
by: sara |
last post by:
I am learning how to use simple functions to make my apps more powerful
and efficient.
On one screen, I want to populate field B: ItemDescription by looking
up the ItemDescription in the Items Table. I would use the key to the
Items Table from the selection the user made in the combo box.
SO: User chooses an item from the combo box whose value is "3". I
want to look up the ItemDescription of the Item with the Key "3" and
show that...
|
by: rdemyan via AccessMonster.com |
last post by:
I have a need to add another field to all of my tables (over 150). Not data,
but an actual field.
Can I code this somehow. So the code presumabley would loop through all the
tables, open each table in design mode and then add the new field and set its
properties.
Thanks.
--
|
by: magickarle |
last post by:
Hi, I got a pass-through query (that takes about 15 mins to process)
I would like to integrate variables to it.
IE: something simple:
Select EmplID from empl_Lst
where empl_lst.timestamp between !! And
!!
Not sure how to do so (should it be a query in Access or a macro)
The connection would be ODBC.
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |