472,954 Members | 2,120 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Use of "Max" in query grid

Good day, and thank you in advance for any assistance you can provide.

I have a table in an Access 2000 .mdb file, and I've run into something odd
and insolvable, at least for me. The database is for membership information.
This particular table, called tblMembershipInfo, has fields/columns as
follows -

fldMemNum - Member Number
fldActionDate - The date when the entry was made in that row - Data type is
Date/Time, no format specified
fldAction - What the entry is for (new membership, adjustment to exp. date,
renewal, etc.)
fldMembershipType - A code telling me if it's a three month, six month or
one year membership and so forth; there are a number of different codes
fldStartDate - The starting date of the membership - Data type is Date/Time,
no format specified
fldExpDate - The expiration date of the membership - Data type is Date/Time,
no format specified

This table, along with a table of stuff like member names and addresses, is
used to generate a mess of reports, membership cards, promotional lists and
the like. That table is called tblMemberInfo; it is the "one" side of a
"one-to-many" relationship with tblmembershipInfo.

In the past, I've used the "Max" function (on the field called "fldExpDate"
in a query to get people's expiration dates, based on the highest expiration
date for the members from the same table. That query has run reliably for
better than a year and I've checked it a couple of times, at random, against
the contents of the tables.

I now want to get people's expiration dates from the most recent record in
the table for any given member. This seemed simple (famous last words) -
here's the SQL I'm trying now, which comes from the SQL page of the QBE
grid -

SELECT tblMemberInfo.fldMemNum, tblMemberInfo.fldFirstName,
tblMemberInfo.fldLastName, Max(tblMembershipInfo.fldActionDate) AS
MaxOffldActionDate, tblMembershipInfo.fldExpDate
FROM tblMemberInfo INNER JOIN tblMembershipInfo ON tblMemberInfo.fldMemNum =
tblMembershipInfo.fldMemNum
GROUP BY tblMemberInfo.fldMemNum, tblMemberInfo.fldFirstName,
tblMemberInfo.fldLastName, tblMembershipInfo.fldExpDate
ORDER BY tblMemberInfo.fldMemNum;

and the query returns all of the entries in the table (about 700, as some
members have two to five entries), including multiple records for those
member numbers that have multiple records. Again, all I want is the
expiration date from the last entry, based on the most recent Action Date in
the table, for any one of the members. I should wind up with a list of
members about 100-110 names long, each with an expiration date after the
date on which the query is run.

I know that my inexperience is causing me to overlook something. I've
checked randomly selected rows to see that the data is true to the date
type - no spaces, blanks and the like. I've made sure that the data types
agree from one table to the next. but I don't see the cause of this. Can
someone point me in the correct direction?

Many thanks.
Steve E.
Nov 13 '05 #1
3 2048
I think that the problem may be including the tblMembershipInfo.fldExpDate
in your query. There will be a different value for each
tblMembershipInfo.fldActionDate

Could be wrong though

Phil

"Serious_Practitioner" <Se************************@att.net> wrote in message
news:Jb*********************@bgtnsc04-news.ops.worldnet.att.net...
Good day, and thank you in advance for any assistance you can provide.

I have a table in an Access 2000 .mdb file, and I've run into something
odd and insolvable, at least for me. The database is for membership
information. This particular table, called tblMembershipInfo, has
fields/columns as follows -

fldMemNum - Member Number
fldActionDate - The date when the entry was made in that row - Data type
is Date/Time, no format specified
fldAction - What the entry is for (new membership, adjustment to exp.
date, renewal, etc.)
fldMembershipType - A code telling me if it's a three month, six month or
one year membership and so forth; there are a number of different codes
fldStartDate - The starting date of the membership - Data type is
Date/Time, no format specified
fldExpDate - The expiration date of the membership - Data type is
Date/Time, no format specified

This table, along with a table of stuff like member names and addresses,
is used to generate a mess of reports, membership cards, promotional lists
and the like. That table is called tblMemberInfo; it is the "one" side of
a "one-to-many" relationship with tblmembershipInfo.

In the past, I've used the "Max" function (on the field called
"fldExpDate" in a query to get people's expiration dates, based on the
highest expiration date for the members from the same table. That query
has run reliably for better than a year and I've checked it a couple of
times, at random, against the contents of the tables.

I now want to get people's expiration dates from the most recent record in
the table for any given member. This seemed simple (famous last words) -
here's the SQL I'm trying now, which comes from the SQL page of the QBE
grid -

SELECT tblMemberInfo.fldMemNum, tblMemberInfo.fldFirstName,
tblMemberInfo.fldLastName, Max(tblMembershipInfo.fldActionDate) AS
MaxOffldActionDate, tblMembershipInfo.fldExpDate
FROM tblMemberInfo INNER JOIN tblMembershipInfo ON tblMemberInfo.fldMemNum
= tblMembershipInfo.fldMemNum
GROUP BY tblMemberInfo.fldMemNum, tblMemberInfo.fldFirstName,
tblMemberInfo.fldLastName, tblMembershipInfo.fldExpDate
ORDER BY tblMemberInfo.fldMemNum;

and the query returns all of the entries in the table (about 700, as some
members have two to five entries), including multiple records for those
member numbers that have multiple records. Again, all I want is the
expiration date from the last entry, based on the most recent Action Date
in the table, for any one of the members. I should wind up with a list of
members about 100-110 names long, each with an expiration date after the
date on which the query is run.

I know that my inexperience is causing me to overlook something. I've
checked randomly selected rows to see that the data is true to the date
type - no spaces, blanks and the like. I've made sure that the data types
agree from one table to the next. but I don't see the cause of this. Can
someone point me in the correct direction?

Many thanks.
Steve E.

Nov 13 '05 #2
Hi, Phil -

Thank you.

I guess I didn't understand the meaning of the term "Max". I thought I'd get
the row with the highest Action date for each member, and then get the Exp
date from that. I followed your suggestion - I took the ExpDate out and I
now get the most recent Action dates - I'll make another query to extract
the most recent Exp Date. Thank you for helping me move on.
Steve E.

"Phil Stanton" <ph******@xxstantonfamily.co.uk> wrote in message
news:42***********************@ptn-nntp-reader02.plus.net...
I think that the problem may be including the tblMembershipInfo.fldExpDate
in your query. There will be a different value for each
tblMembershipInfo.fldActionDate

Could be wrong though

Phil

"Serious_Practitioner" <Se************************@att.net> wrote in
message news:Jb*********************@bgtnsc04-news.ops.worldnet.att.net...
Good day, and thank you in advance for any assistance you can provide.

I have a table in an Access 2000 .mdb file, and I've run into something
odd and insolvable, at least for me. The database is for membership
information. This particular table, called tblMembershipInfo, has
fields/columns as follows -

fldMemNum - Member Number
fldActionDate - The date when the entry was made in that row - Data type
is Date/Time, no format specified
fldAction - What the entry is for (new membership, adjustment to exp.
date, renewal, etc.)
fldMembershipType - A code telling me if it's a three month, six month or
one year membership and so forth; there are a number of different codes
fldStartDate - The starting date of the membership - Data type is
Date/Time, no format specified
fldExpDate - The expiration date of the membership - Data type is
Date/Time, no format specified

This table, along with a table of stuff like member names and addresses,
is used to generate a mess of reports, membership cards, promotional
lists and the like. That table is called tblMemberInfo; it is the "one"
side of a "one-to-many" relationship with tblmembershipInfo.

In the past, I've used the "Max" function (on the field called
"fldExpDate" in a query to get people's expiration dates, based on the
highest expiration date for the members from the same table. That query
has run reliably for better than a year and I've checked it a couple of
times, at random, against the contents of the tables.

I now want to get people's expiration dates from the most recent record
in the table for any given member. This seemed simple (famous last
words) - here's the SQL I'm trying now, which comes from the SQL page of
the QBE grid -

SELECT tblMemberInfo.fldMemNum, tblMemberInfo.fldFirstName,
tblMemberInfo.fldLastName, Max(tblMembershipInfo.fldActionDate) AS
MaxOffldActionDate, tblMembershipInfo.fldExpDate
FROM tblMemberInfo INNER JOIN tblMembershipInfo ON
tblMemberInfo.fldMemNum = tblMembershipInfo.fldMemNum
GROUP BY tblMemberInfo.fldMemNum, tblMemberInfo.fldFirstName,
tblMemberInfo.fldLastName, tblMembershipInfo.fldExpDate
ORDER BY tblMemberInfo.fldMemNum;

and the query returns all of the entries in the table (about 700, as some
members have two to five entries), including multiple records for those
member numbers that have multiple records. Again, all I want is the
expiration date from the last entry, based on the most recent Action Date
in the table, for any one of the members. I should wind up with a list of
members about 100-110 names long, each with an expiration date after the
date on which the query is run.

I know that my inexperience is causing me to overlook something. I've
checked randomly selected rows to see that the data is true to the date
type - no spaces, blanks and the like. I've made sure that the data types
agree from one table to the next. but I don't see the cause of this. Can
someone point me in the correct direction?

Many thanks.
Steve E.


Nov 13 '05 #3
Hi, Phil -

Thank you.

I guess I didn't understand the meaning of the term "Max". I thought I'd get
the row with the highest Action date for each member, and then get the Exp
date from that. I followed your suggestion - I took the ExpDate out and I
now get the most recent Action dates - I'll make another query to extract
the most recent Exp Date. Thank you for helping me move on.
Steve E.

"Phil Stanton" <ph******@xxstantonfamily.co.uk> wrote in message
news:42***********************@ptn-nntp-reader02.plus.net...
I think that the problem may be including the tblMembershipInfo.fldExpDate
in your query. There will be a different value for each
tblMembershipInfo.fldActionDate

Could be wrong though

Phil

"Serious_Practitioner" <Se************************@att.net> wrote in
message news:Jb*********************@bgtnsc04-news.ops.worldnet.att.net...
Good day, and thank you in advance for any assistance you can provide.

I have a table in an Access 2000 .mdb file, and I've run into something
odd and insolvable, at least for me. The database is for membership
information. This particular table, called tblMembershipInfo, has
fields/columns as follows -

fldMemNum - Member Number
fldActionDate - The date when the entry was made in that row - Data type
is Date/Time, no format specified
fldAction - What the entry is for (new membership, adjustment to exp.
date, renewal, etc.)
fldMembershipType - A code telling me if it's a three month, six month or
one year membership and so forth; there are a number of different codes
fldStartDate - The starting date of the membership - Data type is
Date/Time, no format specified
fldExpDate - The expiration date of the membership - Data type is
Date/Time, no format specified

This table, along with a table of stuff like member names and addresses,
is used to generate a mess of reports, membership cards, promotional
lists and the like. That table is called tblMemberInfo; it is the "one"
side of a "one-to-many" relationship with tblmembershipInfo.

In the past, I've used the "Max" function (on the field called
"fldExpDate" in a query to get people's expiration dates, based on the
highest expiration date for the members from the same table. That query
has run reliably for better than a year and I've checked it a couple of
times, at random, against the contents of the tables.

I now want to get people's expiration dates from the most recent record
in the table for any given member. This seemed simple (famous last
words) - here's the SQL I'm trying now, which comes from the SQL page of
the QBE grid -

SELECT tblMemberInfo.fldMemNum, tblMemberInfo.fldFirstName,
tblMemberInfo.fldLastName, Max(tblMembershipInfo.fldActionDate) AS
MaxOffldActionDate, tblMembershipInfo.fldExpDate
FROM tblMemberInfo INNER JOIN tblMembershipInfo ON
tblMemberInfo.fldMemNum = tblMembershipInfo.fldMemNum
GROUP BY tblMemberInfo.fldMemNum, tblMemberInfo.fldFirstName,
tblMemberInfo.fldLastName, tblMembershipInfo.fldExpDate
ORDER BY tblMemberInfo.fldMemNum;

and the query returns all of the entries in the table (about 700, as some
members have two to five entries), including multiple records for those
member numbers that have multiple records. Again, all I want is the
expiration date from the last entry, based on the most recent Action Date
in the table, for any one of the members. I should wind up with a list of
members about 100-110 names long, each with an expiration date after the
date on which the query is run.

I know that my inexperience is causing me to overlook something. I've
checked randomly selected rows to see that the data is true to the date
type - no spaces, blanks and the like. I've made sure that the data types
agree from one table to the next. but I don't see the cause of this. Can
someone point me in the correct direction?

Many thanks.
Steve E.


Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Steve | last post by:
Hi, Is there something fundamentally wrong with the following query? SELECT MAX(OrderID) AS Expr1 FROM Orders WHERE (MarketActionCode = 'S') AND (OrderLegCode = 'S') AND (Status = 'F') AND...
2
by: Alpha | last post by:
I need to find the file and its file name in a directory where the filename is made up with XXXYYYYMMDDXXX.mdb The date is embedded in the middle of the file name. The prefix and postfix of...
1
by: Vladimir Davidov | last post by:
Hello everybody! I realize that the problem, I will ask for solution of, has been posted here once, but none of the replies would actually solve it. So I will try again - there is one project,...
8
by: abcd | last post by:
I can get the value on the form at the server side by using Request.form("max") when max field is disabled I dont get value. For GUI and business logic purpose I have disabled some fields with...
1
by: Thomas Qi | last post by:
There is a basic sql below: SELECT CTEnr AS ID, TimeStamp, DatagramSize, Source AS LocalIP, Destination AS RemoteIP, Protocol, Messages, SourcePort AS LocalPort, DestPort AS RemotePort FROM...
10
by: JDT | last post by:
Hi, Can someone provide me an example that uses std::max_element() (probablly the predicate version) to return the max "absolute" integer in a vector? Your help is much appreciated. Tony ...
3
by: lawrence k | last post by:
This is weird. When I use getId3 to try to read meta tags out of multimedia files, I get this error: Fatal error: Maximum execution time of 30 seconds exceeded in /home/...
3
by: jclover | last post by:
When creating a query in Access (assumption is the data has a unique ID which is numerical...new records, autonumber) how reliable is the "Last of" grouping function vs the "Max of" the ID, and then...
10
by: anonymous | last post by:
How can I set report output parameter "Page 1 of max" to get output on first page in minimum time as it takes much time in fetching max page no. in first page and report is of around million pages
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
1
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.