Okay, woo, yet another issue I have. I remember writing about this issue
AGES ago, but I don't think it worked, or I just left it for too long.
I have a query that searches for specific records according to the invoice
number. It will display information from two tables, Customer Details and
Invoices. The result is sorted in terms of a field called JobNo. So to make
it simple, if I wanted a query to display all the entries for invoice number
4227, I would get a result similar to the following:
JobNo NAME
100 Jimmy Buffet
100 Pablo Picasso
100 Harry Potter
101 Seth Green
101 Pam Anderson
102 Gary Oldman
What I want in my query is to only display one result per job number, so
when I get the result for the query, it would appear like this:
JobNo NAME
100 Jimmy Buffet
101 Seth Green
102 Gary Oldman
It doesn't matter which name I get, it is the Job number and the other
details in my query that are important.
Any help?
Thank you,
Tom Keane 4 1798
Tom Keane wrote: Okay, woo, yet another issue I have. I remember writing about this
issue AGES ago, but I don't think it worked, or I just left it for too
long. I have a query that searches for specific records according to the
invoice number. It will display information from two tables, Customer Details
and Invoices. The result is sorted in terms of a field called JobNo. So
to make it simple, if I wanted a query to display all the entries for invoice
number 4227, I would get a result similar to the following:
JobNo NAME 100 Jimmy Buffet 100 Pablo Picasso 100 Harry Potter 101 Seth Green 101 Pam Anderson 102 Gary Oldman
What I want in my query is to only display one result per job number,
so when I get the result for the query, it would appear like this:
JobNo NAME 100 Jimmy Buffet 101 Seth Green 102 Gary Oldman
It doesn't matter which name I get, it is the Job number and the
other details in my query that are important. Any help?
Thank you, Tom Keane
Note that Name is a reserved word in Access so naming a Field 'Name' is
not a good idea. If qryJobsByInvoice is your query that displays:
JobNo theName DataField
100 Jimmy Buffet BuffetData
100 Pablo Picasso PicassoData
100 Harry Potter PotterData
101 Seth Green GreenData
101 Pam Anderson AndersonData
102 Gary Oldman OldmanData
then
SELECT JobNo, First(theName) AS ContactName, First(DataField) AS Data
FROM qryJobsByInvoice GROUP BY JobNo;
should give:
JobNo ContactName Data
100 Jimmy Buffet BuffetData
101 Seth Green GreenData
102 Gary Oldman OldmanData
James A. Fortune
> SELECT JobNo, First(theName) AS ContactName, First(DataField) AS Data FROM qryJobsByInvoice GROUP BY JobNo; should give:
JobNo ContactName Data 100 Jimmy Buffet BuffetData 101 Seth Green GreenData 102 Gary Oldman OldmanData
When I do this, an error message comes up saying
"You tried to execute a query that does not include the specified expression
'JobNo' as part of an aggregate function"
It pretty much doesn't let me do anything unless I have the First()
expression around it. But if I do that it only displays the very first
record, not the first record for each job number.
What can I do to fix this?
Thank you for your help,
Tom
Tom Keane wrote: SELECT JobNo, First(theName) AS ContactName, First(DataField) AS
Data FROM qryJobsByInvoice GROUP BY JobNo; should give:
JobNo ContactName Data 100 Jimmy Buffet BuffetData 101 Seth Green GreenData 102 Gary Oldman OldmanData
When I do this, an error message comes up saying
"You tried to execute a query that does not include the specified
expression 'JobNo' as part of an aggregate function"
It pretty much doesn't let me do anything unless I have the First() expression around it. But if I do that it only displays the very
first record, not the first record for each job number.
What can I do to fix this?
Thank you for your help, Tom
You need to change the Name field to theName in both the table and the
query. If that's not possible just change it in the query using QBE
like: theName: Name. Also, your query must include the name of the
data field that you want to include instead of just the two fields you
show. Replace 'DataField' with the actual name of the field from the
table in qryJobsByInvoice and in the new query. That should fix the
problem. If not, post back with the SQL you use for qryJobsByInvoice
and I'll try to show you what the final query should look like.
James A. Fortune
> You need to change the Name field to theName in both the table and the query. If that's not possible just change it in the query using QBE like: theName: Name. Also, your query must include the name of the data field that you want to include instead of just the two fields you show. Replace 'DataField' with the actual name of the field from the table in qryJobsByInvoice and in the new query. That should fix the problem. If not, post back with the SQL you use for qryJobsByInvoice and I'll try to show you what the final query should look like.
It works now. Thanks ;) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Greg |
last post by:
I am working on a project that will have about 500,000 records in an XML
document. This document will need to be queried with XPath, and records
will need to be updated. I was thinking about...
|
by: Emilio |
last post by:
(MS Access 2002)
Hello, I'm working with some big Census (PUMS) files, and I run into a
peculiar problem once the data field exceeds five integers. I'll explain
every step, since I am doing it in...
|
by: Matt K. |
last post by:
Hi there,
I have a form in an Access project that contains a subform which
displays the results of a query of the style "select * from
where = #a certain date#". In the main part of the form...
|
by: Stewart Allen |
last post by:
I'm trying to filter a table that has 2 date fields, the first date will
always have a value but the second will only occasionally has a value. Each
date field also has a corresponding text field...
|
by: SueB |
last post by:
Greetings. I have a report based on the following query (hang in there
... it's quite long):
SELECT Year(.) AS Yr, tblEvents.eventID,
tblEvents.eventname, tblEvents.eventhost,...
| |
by: RAJ |
last post by:
In our multi-tier application, we have several ASP.NET user controls which
will update the same data source provided by middle tier logic.
In this particular scenario we have one user control...
|
by: commanderjason |
last post by:
This seems like a very simple question but i have never been able to
find an easy answer to it.
I have a user table and i do a join with another table, we'll call the
other table a results...
|
by: Richard Carpenter |
last post by:
I understand how to use a dropdown list control to display the
associated description value for a foreign key in a parent rather than
the key itself, but I don't like having to disable the control...
|
by: bimeldip |
last post by:
Hi,
i would like to display the list of tables in a database in a drop down list
then when user selects a table, the table will be dispalyed on the page.
So far i've done this:
<?
$dbname =...
|
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...
|
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...
| |
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,...
|
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...
|
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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
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...
|
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...
| |
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 ...
| |