I have a table for water monitoring sites, each site has a SiteNo (site number) field and in another table each site has details of a number of samples taken at that site, including the date taken, What I need is a query which gives me details of the sites with the first and last date on which a sample was taken for each site. The following code gets me the earlies sample in the sample table, but what do I put in the third part of the DMin to get it for each site? - EarliestSample: DMin("[Date]","tblSample")
It's got to be something like
but what? Should I compare it to something else in the query
or something on the report where the query is the Control Source?
Thanks in advance, and
Go Mary, Go (9K!)
(Edit: Actually, everybody in the top 10 with the exception of JosAH and possibly r0 (and pbmods who hase just clocked one) are in the final stages of the next K. Way to go troops!)
Jim
4 1299
I have a table for water monitoring sites, each site has a SiteNo (site number) field and in another table each site has details of a number of samples taken at that site, including the date taken, What I need is a query which gives me details of the sites with the first and last date on which a sample was taken for each site. The following code gets me the earlies sample in the sample table, but what do I put in the third part of the DMin to get it for each site? - EarliestSample: DMin("[Date]","tblSample")
It's got to be something like
but what? Should I compare it to something else in the query
or something on the report where the query is the Control Source?
Thanks in advance, and
Go Mary, Go (9K!)
(Edit: Actually, everybody in the top 10 with the exception of JosAH and possibly r0 (and pbmods who hase just clocked one) are in the final stages of the next K. Way to go troops!)
Jim
Hi Jim,
Add your primary table to your query grid. Add your Child table twice.
Join them all on the ID/FK field
Drag your ID field from your primary down to the query grid.
Drag your date field down from the 1st child table
drag your date field down from the 2nd child table
now use the group by thing...for the id
use the Min for the first date field
Use the Max for the second.
That's it!
Example -
SELECT Table1.ID, Min(tblDateMax_1.date1) AS MinOfdate1, Max(tblDateMax_2.date2) AS MaxOfdate2
-
FROM (Table1 INNER JOIN tblDateMax AS tblDateMax_1 ON Table1.ID = tblDateMax_1.ID) INNER JOIN tblDateMax AS tblDateMax_2 ON Table1.ID = tblDateMax_2.ID
-
GROUP BY Table1.ID;
-
J
Hi Jim,
Add your primary table to your query grid. Add your Child table twice.
Join them all on the ID/FK field
Drag your ID field from your primary down to the query grid.
Drag your date field down from the 1st child table
drag your date field down from the 2nd child table
now use the group by thing...for the id
use the Min for the first date field
Use the Max for the second.
That's it!
J
You're good, you're darn good!
If you're the Houston, Tx of programming (I snuck a look at your profile), then I'm the San Angelo!
Thank you so much.
Jim
You're good, you're darn good!
If you're the Houston, Tx of programming (I snuck a look at your profile), then I'm the San Angelo!
Thank you so much.
Jim
Happy to help. And Thanks for the kudos!
J
Happy to help. And Thanks for the kudos!
J
A supplementary question, if you're still watching this thread. Is it having the same table in a query twice that massively increases the running time of the query?
Jim
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Charles Jamieson |
last post by:
I am getting an inexplicable compile-time error message. Here is the code
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#include <string>
class CBerk
{
public:...
|
by: mike |
last post by:
I have a location table that contains all North American zip codes, the
city, county, state etc.. each record has a GUID. My problem is that
several places in the US you will have a single city...
|
by: eddiec |
last post by:
hi everyone,
I have a report in an adp that uses aggregate functions in its record source
and I am trying to figure out how to filter the records displayed in the
report:
DoCmd.OpenReport...
|
by: Not Me |
last post by:
Hey,
I have a report featuring a handful of subreports, a field taking values
from the main record source, and a field in the report footer which
displays the sum of values in said field.
The...
|
by: cmay |
last post by:
I am trying to build more applications using a more OO approach, with
more seperation of business and presentation logic.
One problem I am running into involves the design philosophy behind...
|
by: S P Arif Sahari Wibowo |
last post by:
Hi!
I would like to make an editable continous form, where most
fields will be from table A and editable, except 1-3 fields are
a glimpse into table B and uneditable. Table A relate to table B...
|
by: Dean |
last post by:
Has anyone toiled with creating/using alternate domain aggregate
functions? I have been messing with that a little. The one
recordsource I have been working indicates I get 20 to 40% savings in...
|
by: Ian825 |
last post by:
I need help writing a function for a program that is based upon the various operations of a matrix and I keep getting a "non-aggregate type" error. My guess is that I need to dereference my...
|
by: wrldruler |
last post by:
Hello,
First, I know it's against "Access Law" to save calculations in a
table, but....I want/need to.
I currently have sub-totals being calculated inside a form, using
DMax, DCount, and...
|
by: vincibleman |
last post by:
Howdy all,
Working my way into SQL from Access. Think I might have the hang of the basics, but would really appreciate a sanity check. The stored procedure listed below works, but I can't help...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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: 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...
| |