Hello-
I'm having a little trouble. I want to create a query that will return the most recent records (by date) for all unique values in a certain field in the query. I'll be pulling data from 3 different tables as well. Since my description is usually inadequate, here's a simple example:
Before Query:
Date Field
1/1/07 A
1/2/07 A
1/2/07 B
1/2/07 C
1/3/07 A
1/4/07 B
After Query:
Date Field
1/3/07 A
1/4/07 B
1/2/07 C
Does that make sense? Is there a simple solution?
10 7937 MMcCarthy 14,534
Recognized Expert Moderator MVP
For one table the solution would be - SELECT Max([Date]), Field FROM TableName
-
GROUP BY Field
As for joining three table I would need more information. If you can post the actual meta data of the tables as well as details of what you want returned we will try to help.
Here is an example of how to post table MetaData : Table Name=tblBookings - Field; Type; IndexInfo
-
StudentID; Autonumber; PK
-
Family; String; FK
-
Name; String
-
University; String; FK
-
Mark; Numeric
-
LastAttendance; Date/Time
hey there,
i was searching for solutions to my problem and came across this discussion. this is the EXACT problem i am having.
I want to pull the most recent date from the "status subform" pulls the project "name" from its main form.
I tried using Max(Date) to get the most recent date, however it only pulls "1/4/07 B" which is the latest of ALL the dates, not just he "B" dates. (from above illustration)
i tried matching it to the main table as well but that isn't working either :S
Any suggestions?
MMcCarthy 14,534
Recognized Expert Moderator MVP
hey there,
i was searching for solutions to my problem and came across this discussion. this is the EXACT problem i am having.
I want to pull the most recent date from the "status subform" pulls the project "name" from its main form.
I tried using Max(Date) to get the most recent date, however it only pulls "1/4/07 B" which is the latest of ALL the dates, not just he "B" dates. (from above illustration)
i tried matching it to the main table as well but that isn't working either :S
Any suggestions?
Try using DMax.
=DMax("[Date]","TableName","[name]='" & [Forms]![MainFormName]![name] & "'")
Try using DMax.
=DMax("[Date]","TableName","[name]='" & [Forms]![MainFormName]![name] & "'")
hey sorry to be a bother (pure newb and self taught one at that) i used DMax but am getting the msg "enter parameter value"
here are the tables, forms and fields im dealing with
Main form = Status>>>Table = Project Management...Relevant Field = Project Name
Sub form = Status Updates Subform>>>Table = Status Updates Sub...Relevent Field = "Date"
Thanks again for the help
MMcCarthy 14,534
Recognized Expert Moderator MVP
I have to go out for a couple of hours. I'll look at this when I get back if someone hasn't already posted on it.
I have to go out for a couple of hours. I'll look at this when I get back if someone hasn't already posted on it.
alright not a problem, thank you!
hey jconstan
i think i am having the same problem
i currently have a sub datasheet in one of my queries, which feeds into a report.
i am wondering how to filter the sub datasheet to show the latest update, which is what i think you are doing as well.
i think if you use a sub datasheet as i did it will save some problems, such as being able to bring up all the updates for a specific record...although then you get my problem which is i can not filter the sub datasheet :S
let me know how its goin
MMcCarthy 14,534
Recognized Expert Moderator MVP
hey sorry to be a bother (pure newb and self taught one at that) i used DMax but am getting the msg "enter parameter value"
here are the tables, forms and fields im dealing with
Main form = Status>>>Table = Project Management...Relevant Field = Project Name
Sub form = Status Updates Subform>>>Table = Status Updates Sub...Relevent Field = "Date"
Thanks again for the help
My apologies, this got lost in the shuffle.
OK, try this (the "Status Updates Sub" table has to have a field [name] which corresponds to the same project name in the main form)
=DMax("[Date]","Status Updates Sub","[name]='" & [Forms]![Status]![Project Name] & "'")
can you query the date within the report instead? maybe that will work?
MMcCarthy 14,534
Recognized Expert Moderator MVP
hey there thanx for the response,
i tried using the code, however it is telling me to enter the parameter value: forms!Status!Project Name!...the form name and field are both correct so i dont know what the problem is :S
As this post is from Leanne, I'm confused?
Why is there an exclamation mark after ProjectName?
If the field ProjectName has a space then it needs to be enclosed in square brackets as follows:
Forms!Status![Project Name]
Edit: As the last post has been edited this doesn't make sense to the thread any more. Please don't play around like this or the experts will get very annoyed and not be inclined to assist you.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Toucan |
last post by:
i need to retrieve the most recent timestamped records with unique
names (see working query below)
what i'm having trouble with is returning the next-most-recent records
(records w/ id 1 and 3...
|
by: Willem |
last post by:
Hi there,
I'm sort of new with doing much record manipulation with queries. Up
till now I've been programming VBA and doing record looping to get my
results. This works fine but tends to get...
|
by: John |
last post by:
I have a query that returns this recordset:
Bob, 1/1/2000
Bob, 3/1/2001
Bob, 2/4/2004
Bob, 5/9/2002
I need the query to return this instead:
Bob, 2/4/2004
So, it needs to return the most...
|
by: suffrinmick |
last post by:
Hi everyone!
I (Along with the help of some of you guys!) have managed to get a
query working which takes multiple values (types of organisation) from
a list box.
The query returns a list of...
|
by: Maxi |
last post by:
There is a lotto system which picks 21 numbers every day out of 80
numbers.
I have a table (name:Lotto) with 22 fields (name:Date,P1,P2....P21)
Here is the structure and sample data:
...
| |
by: c tom |
last post by:
id name location
1 tom new york
2 jeny sicago
3 tom new york
4 luca sidney
5 luca sidney
i want to make below table using query.
id name location
|
by: Mike Curry |
last post by:
I have run into a problem, I have 2 fields in my database, both key
fields:
Table 1
=====
Field X <key>
Field Y <key>
In field X, there are say about 3 records for each unique Field Y. I...
|
by: Jimmy Stewart |
last post by:
Ok, I'm trying to write a query that is starting to wear me down.
What I'm trying to do is create a year end report that gets sent to all of
my customers who meet two criteria. One they are...
|
by: Kelii |
last post by:
I've been trying to get this piece to work for a few hours, but have
given up. I hope someone out there can help, I think the issue is
relatively straightforward, but being a novice, I'm stumped....
|
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: 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: 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...
|
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: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |