Querying The Most Recent Record

Jul 6, 2005

I have a TRANSACTIONS table that adds a new record each time a customer makes a payment. Fields are: our account number, date of payment and amount of payment. Our account number has a relationship with the main CUSTOMERS table which never changes.

I need to query out the most recent payment record for each customer in order to arrive at the most recent date a payment was made.

I've been looking over my books and having a hard time figuring out how to do this. Any help will be appreciated.

Thanks,

Mark A.

View Replies


ADVERTISEMENT

Find Most Recent Invoice And Most Recent Funding For Client

Feb 19, 2008

Hello all

I'm sure the answer is on here somewhere but trying to find it and then getting it to work is a bit of a problem, so i resorted to posting.

I have 5 tables
Partnership Details, Invoices, Funding, Communication, Communication Types.

the field Partnership Name in the Partnership Details table has a one to many relationship with the partnership name on tables: Invoices, Funding and Comunication.

What I want to do is create a query that will show the most recent invoice (detirmined by date) and the most recent funding (detirmined by date) for each partnership.

I can do this using max if I only want the feilds Partnership name, invoice date and funding date. however I want to create a report that will show several feilds from partnership details and I want to show the invoice no. and amount as well as the date and also the amount and notes field for funding

Is anyone able to help?

Thanks
Niyx

View 3 Replies View Related

Replacing Most Recent Record

Dec 11, 2007

Hi, Im building a DB that basically tracks the hours people have worked,
its all going fine apart from one major bug which i cant get my head around, I am trying to work out a way so that if someone decides to change the hours they have worked it replaces the existing record and does not create a new record.

Each record has a unique user ID attached and each day is dated, do you think this is a VBA solution or a change in the relationships perhaps?

Sorry fi there is already a similar answer to this question on the forum, but i couldnt find one!:confused:

Thanks in advance,

Paul

View 2 Replies View Related

Display ONLY Most Recent Record

Jun 14, 2006

My form has a button that opens a report. This report is based on a query that sets the report to display ONLY information related to the person in the current query record.

How can I get the report/query to display ONLY the last (most recent) record in the query?

View 2 Replies View Related

Most Recent Record First On Form?

Jan 3, 2005

Hi--I have a subform where a contact's contributions are entered. After much wrangling with the subform's properties, I finally got more than one record to display at a time, but is there a way to get the contributions displayed in descending order (i.e. more recent to less recent) without having to totally redo the subform by basing it on a new underlying query? I tried sorting the contribution date of the underlying bound table that way, but it had no effect.

Thanks for any help.

TDP

View 3 Replies View Related

Finding The Most Recent Record

Jul 16, 2005

I have a database with many tables, but only two are relevant to my question.

tblPersonnel holds (amongst other fields) UniqueStaffNo (primary key), Name, Dept, FirstAider (Yes/No).

tblCourses holds details of all courses attended by staff and is linked to tblPersonnel by the UniqueStaffNo. Fields in this table include the CourseTitle and CourseDate (short date format).

I can easily identify who is a First Aider by selecting on tblPersonnel.FirstAider and I can identify which of the thousands of course records are First Aid related by looking at tbl.CourseTitle.

My question is - how can I produce a list of all current first aiders showing ONLY their most recent first aid course (latest CourseDate) so that I can calculate when they need to renew their certificate?

Any help more than gratefully received. Thanks.

View 1 Replies View Related

Extracting Record(s) With Most Recent Date

Jul 29, 2006

I have a database table comprising inspection records for about 300 process control instruments. A new record is entered for each inspection so that an inspection history builds up for each instrument.

For one report I need to extract all the records with the only the latest inspection date for each instrument.

I attempted to build a query using the design grid screen. Initially I thought I could use the "Max of" approach as I have done with numbers. This did not work so tried without success to convert the dates to serial format thinking I could "Max of".

Have now concluded that a module is needed. However with my Access Basic programming skills this would take me a couple of weeks and still be wrong!

Can anyone point me in the right direction?

View 12 Replies View Related

Query/report To Display Most Recent Record

Jun 1, 2006

My database includes a Project table and a Status table. They are linked by the ProjectID. The status table contains records sorted by date pertaining to work accomplished on each project. I have created a report based upon a query to give me an update of the status of each project. I only want to see the most recent record for each project from the Status table in my report.

How can I accomplish this?

View 7 Replies View Related

Queries :: Get Most Recent Record Based On 3 Different Fields

Jun 2, 2014

I have a table similar to the following:

PatientID | LabID | LabDate | Result
001 | 55 | 01jan14 | 9.5
001 | 55 | 01feb14 | 10.0
001 | 55 | 01mar14 | 8.7
001 | 66 | 30jan14 | 11.2
001 | 66 | 30feb14 | 15.4
001 | 66 | 30mar14 | 13.0

002 | 55 | 01jan14 | 12.1
002 | 55 | 01feb14 | 9.9
002 | 55 | 01mar14 | 14.5
002 | 66 | 30jan14 | 16.5
002 | 66 | 30feb14 | 13.0
002 | 66 | 30mar14 | 10.0

Using a single-step Access query, I need to retrieve, for each PatientID, the most recent LabDate and Result *of a given LabID*. Thus, from the example dataset above, the desired output for LabID 55 is:

PatientID | LabID | LabDate | Result
001 | 55 | 01mar14 | 8.7
002 | 55 | 01mar14 | 14.5

I have searched this forum and others, but have not found an answer that I can directly tanslate to my situation. I have successfully written queries (with included subqueries) that retrieve the most recent of all the Labs, but have failed at obtaining a result dataset that contains only the records within a specified LabID.

For example, the query below fails because whenever the most recent of *all* the LabDates is not the same as the most recent of *the LabDates with a LabID=55*, the correct record is not included in the results. In the example dataset above, 0 records are returned.

SELECT a.PatientID, a.LabID, a.LabDate, a.Result
FROM Labs AS a
INNER JOIN (SELECT PatientID, MAX(LabDate) AS MaxLabDate FROM Labs GROUP BY PatientID) AS b
ON (a.PatientID = b.PatientID) AND (a.LabDate = b.MaxLabDate)
WHERE (((a.LabID)=55));

View 3 Replies View Related

Queries :: JOIN Query To Return Most Recent Record?

Aug 18, 2014

I have two tables with a one to many relationship. The tables are linked by the INDEX column.

EXAMPLE:

Code:
TABLE_1
INDEX NAME
1 Name_A
2 Name_B
3 Name_C

TABLE 2
INDEX NUM_INDEX STATUS
1 1 REJECTED
1 2 REJECTED
1 3 OPEN
2 1 CLOSED
3 1 REJECTED
3 2 OPEN

I need the NAME field from TABLE_1 and the Last STATUS field from TABLE_2 (MAX of NUM_INDEX).

Example:
Name_A, OPEN
Name_B, CLOSED
Name_C, OPEN

SQL that I have now.

Code:
SELECT A.FIN_Finding_Number, B.Max_Index
FROM TBL_Findings AS A INNER JOIN (SELECT RES_Finding_Index, Max(RES_Response_Index) As Max_Index
FROM TBL_Response GROUP BY RES_Finding_Index ) AS B ON A.FIN_Finding_Index = B.RES_Finding_Index
WHERE (((A.FIN_Finding_Index)=34));

This SQL statement will return me the Finding_Number and Max_Index. I don't need the Max_Index. I need the Status. If I put the Status in the Sub-Query and GROUP BY it, it will return both REJECTED and OPEN. I just need it to return OPEN.

View 2 Replies View Related

Queries :: Subquery To Return Latest / Most Recent Value For Each Record In Main Query

May 7, 2014

I have a table of accounts and a table of rates. There is a one-to-many relationship between them (i.e. each account can have multiple rates, each with their own - unique - effective date)

I'm trying to build a query which will show me all of the accounts in the accounts table and the most recent rate (based on the effective date) for each of those accounts.

This is as far as I've gotten with the SQL :

Code:
SELECT [tblAccounts].[AccountID], [tblAccounts].[AccountNumber], [tblAccounts].[AccountName], [LatestRate].[IntRate], [LatestRate].[EffectiveDate]
FROM [tblAccounts]
LEFT JOIN
(SELECT TOP 1 [tblRates].[AccountID], [tblRates].[IntRate], [tblRates].[EffectiveDate]
FROM [tblRates]
ORDER BY [tblRates].[EffectiveDate] DESC) AS LatestRate
ON [tblAccounts].[AccountID] = [LatestRate].[AccountID]

But this can't work because the [LatestRate] subquery can only ever return one record (i.e. the most recent rate across all of the accounts)

I need the most recent rate for each of the accounts in the main query

(FYI - I use an outer join as it is possible for no rate to be available in the rates table for a given account, in which case I want to return the null value rather than omit the account from the resulting dataset...)

View 2 Replies View Related

Queries :: Appointment Database - Query Most Recent Entry For Each Record In Separate Table

Jun 20, 2013

I have a database that is used to allocate appointments to our staff. It has 2 tables, one that lists the clients we need to call in that day, and another that stores details of each contact attempt. I'd like to design a query that find all clients who we have not dealt with so we can easily get their details in a list. I know what the criteria for the query would be, but I'm stuck for how to actually execute it. Here are the details.

Table tClients stores the current clients - primary key is named "clientRef"
Table tContactEvents stores each contact attempt and the date/time is stored in a field named "dateTime".

When an entry has been dealt with successfully a yes/no field named "completed" will be set to "Yes".

There may be many attempts to contact a specific client on a given day, unsuccessful attempts will not have the completed flag set.

Once the completed flag is set that client will be ignored so no further entries will appear.

So I need a query that searches tContactEvents for the most recent match to each number in tClients.clientRef and checks if the completed flag is set. If the completed flag is false, or if the number has no match (i.e. no contact attempts made yet) then the clientRef should be displayed. I also need this to be restricted to the current date, as the same client could have rebooked their appointment to a different day.

View 10 Replies View Related

Reports :: Select Most Recent Record From A Table That Is Linked To Another Table

Jul 13, 2014

I have a basic database design, well I think so anyway. It only has two tables:

1. tblClientInfo
2. tblNotes

Basically each client has multiple notes/comments that can be linked to its record, hence the tblNotes table. The two tables have a one-to-many relationship, being that each customer can have many notes.

I then have two forms:

1. Claims Loss Form
2. tblNotes_DatasheetSub1

So I can enter multiple notes for each customer. The problem I am having is with the report output. It wants to print every note (record) that is linked to the customer. I just need it to print the most recent note for each customer (It would save a lot of wasted paper).

Example of a print out of what it is doing:

John Doe - 123 Easy St - Notes 1 (Most Recent Note)
John Doe - 123 Easy St - Notes 2 (Previous Note)
John Doe - 123 Easy St - Notes 3 (and so on...)

It is printing duplicates of the same customer by adding the additional notes for that same customer on a new line.

How can I tell it to only print the customer one time in the report, and most importantly, to only use the most recent note that is linked to the customer?

I tried using DMax("NoteDate","tblNotes"), but this only returns one customer with one note. I need it to do that for each and all customers.

I have successfully ran a subquery (two queries with one linked to another) by following detailed instructions from this page I found: [URL] .... It works, but the problem is it only shows the latest date for each note, not the actual contents of the note. I feel so close with this option, but so far at the same time.

The TOP n records per group looks promising that I found here: [URL] ...., but I honestly don't know how to implement it correctly in my SQL. I am very much still learning Access and apparently have stumbled into something that is much more complicated than I had originally imagined. I just assumed I could filter the duplicates out, or tell access to print the last or most recent note record for each customer.

View 2 Replies View Related

SUM Querying

May 15, 2006

Hi I'm having a bit of a problem with the sql query below


SELECT [Table 1 Personal Details].Surname, Sum([Table 3 Daily Activity].[Public Holiday]) AS [SumOfPublic Holiday], [Table 3 Daily Activity].[Week Commencing], Sum([Table 3 Daily Activity].[Authorised Absence]) AS [SumOfAuthorised Absence], Sum([Table 3 Daily Activity].Holiday) AS SumOfHoliday, Sum([Table 3 Daily Activity].Sickness) AS SumOfSickness, Sum([Table 3 Daily Activity].[Unauthorised Absence]) AS [SumOfUnauthorised Absence], Sum([Table 3 Daily Activity].[Hours Per Week]) AS [SumOfHours Per Week], [Table 9 Funding].Project
FROM [Table 1 Personal Details] INNER JOIN ([Table 3 Daily Activity] INNER JOIN [Table 9 Funding] ON [Table 3 Daily Activity].[ID Number] = [Table 9 Funding].[ID Number]) ON [Table 1 Personal Details].[ID Number] = [Table 3 Daily Activity].[ID Number]
GROUP BY [Table 1 Personal Details].Surname, [Table 3 Daily Activity].[Week Commencing], [Table 9 Funding].Project
HAVING ((([Table 3 Daily Activity].[Week Commencing]) Between [Enter Start Date] And [Enter End Date]) AND (([Table 9 Funding].Project)="NETWORKS"))
ORDER BY [Table 3 Daily Activity].[Week Commencing];


My problem is that the Surname is displaying for each record.. what I mean is that I want the surname to be grouped so that I get the SUMofHours summed correctly?

here's an example of what I'm getting

SURNAME, WEEK COMMENCING, SUM OF HOURS, PROJECT

Brown,13/02/2006,35,NETWORKS
Brown,20/02/2006,35,NETWORKS
Malcolm,13/02/2006,35,NETWORKS
Malcolm,20/02/2006,35,NETWORKS



Here's what I'm really looking for though

Brown,13/02/2006,70,NETWORKS
Malcolm,13/02/2006,70,NETWORKS


I need the Hours SUMMED with no replication of surname.

Thanks
CJ


Thanks
CJ

View 3 Replies View Related

Most Recent Entry

Aug 11, 2005

I have a table called Tests that contains 80+ tests that need to be performed on our system. A second table is Test_Data. It contains the test results. I need a query that will pull the most recent test data for each test in the Tests table. So supposing there are 83 tests, I should only get 83 results from my query. I am will need to join the tables as I need to get some of the descriptive information from the Tests table. Another problem I have is some tests have not been performed even once, so not every item in the Tests table has a corresponding entry in the Test_Data table.

Any thoughts on how to do this?

View 4 Replies View Related

10 Most Recent Entries

Apr 6, 2006

Hi,

I am trying to set up a query which will filter out the 10 most recent additions by date.

My table contains a 'Title' field and a 'Date Added' field. I am trying to get the 10 most recent titles up in a query so I can then create a report based on this.

So far I have managed to single out the most recent date simply by using the MAX function but am a bit lost from there on..:(

View 2 Replies View Related

4 More Recent Notes

Apr 29, 2008

Hi, I have a a table that keeps notes about the status of an invoice. It can have 1 or a lot of notes per invoice. I need it to just display the last 4 notes for each invoice. I used TOP 4 but it only shows the top 4 notes and note the top 4 notes for each invoice. Can anyone help?

View 8 Replies View Related

How To Get The Most Recent Value From A Column ?

Jul 3, 2005

Hi every body. I want create a query that has the following fields on it:

Project : project number
Year: year that project is carried out
Weekno: week no that project is carried out
Task: Task number that is done for this project
Employee: employee number that did this task
Amount: amount of salary given for this employee for this particular project

I used access query designer and selected the db_hours_worked table and dbo_hourly_wages I joined the employee fields together and project fields together. But I cannot join weekno in both tables together since an employee
can have different salary in different weeks!

Amount is calculated by multiplying the number of hours worked during this week multiplied by most recent salary of that employee for the particular project. I be happy if some one show me how I can get the most recent salary of employee from dbo_Hourly_wages table then multiply it by number of hours worked this week and put it in amount column. For the current population of db_hourly_wages as u can see in the picture posted the amount that I want to use for amount calculation is 40.

I managed to write part of the query but it does not out put a result and also it does not calculate the salary amount. Thanks

- One employee can work in more then one project
- One employee can have more then one salary (amount) for the same
project because he might get raise in salary!
- Only tasks carried this week will be printed in the weekly report


Code:SELECT dbo_Hours_worked.Project, dbo_Hours_worked.Year, dbo_Hours_worked.weekno, dbo_Hours_worked.Task, dbo_Hours_worked.Employee, dbo_Hourly_wages.amountFROM dbo_Hours_worked INNER JOIN dbo_Hourly_wages ON (dbo_Hours_worked.Employee = dbo_Hourly_wages.Employee) AND (dbo_Hours_worked.Project = dbo_Hourly_wages.Project);
http://i5.photobucket.com/albums/y180/method007/constraint.jpg
==>pic of database

http://i5.photobucket.com/albums/y180/method007/reporterror2maximumofamount.jpg
===> pic of hours wages table
http://i5.photobucket.com/albums/y180/method007/reporterror1.jpg
====> pic of query in design view
http://i5.photobucket.com/albums/y180/method007/queryresult.jpg
====pic of query result

View 1 Replies View Related

Querying An Old Database

Jun 29, 2006

Hey all,

Here is my problem, im working on an old 97 database that is being used by a program and sometimes errors occur through the use of the program and certain tables are not updated properly, so instead of doing this manually I want to be able to query this database through SQL and then later down the line put these SQL queries into a program so it will be more user friendly to edit the database.

So when I try and test one of my queries out, access tells me that I cant make changes to the database because it was created in an earlier version. Now I know i can update the database, but if I were to do that the program that is using the database wont work!

So im a little stuck now, will I have to keep editing the database the manual way or is there another option here? Im wondering (for any java heads out there) If I were to write a java program that would query the database and edit the data inside would that work or would I get back an error?

Thanks in advance!

View 5 Replies View Related

Querying Issues

Jun 16, 2005

Ok, I have a DB of client contacts. I'm drawing the values for a query from a form using [Forms]![Sort]![Contact] in criteria and using the parameter field to give values to each. The query works fine for state, contact and industry- all in conjunction with each other. Where I am having problems is:

1) When I input less then all 3 working parameter values in the referenced form the query will not run. I think i need an SQL string of some sort- doing an if, then relationship, but I don't know how to do this.

2) I don't just have 3 values I want to reference, I have 9 total. On the form one of the problems is that a field is chosen by the end-user using check boxes (allowing only one check between three values, with no default: current client, potential client, not applicable are the choices). However, in the table these are referenced by the values of 1, 2 or 3. Another of my fields is check boxes, but referenced by yes, no. How do I correspond the field values in text to numerical values in the table? (and the yes/no prbly the same I will assume)

3) I have "sectors" as a field option in my Sort form (again the drop down menu to select). There is one field for the choice, however, in my data table I have 4 fields corresponding all back to that one field in the form through the query. This doesn't seem to work at all. The sector choices, in my original Input form, are 8, chosen and recorded into the table using 4 consecutive drop downs. They are the same 8, so sometimes a sector like Agriculture could end up in the Sector 1, or Sector 2, etc field in the table. Some can also be left blank. So in summary of this dilemma: 4 drop downs in input form to 4 data table fields, all being queried through one field on the Sort form, which is tied to my query through a command button, having specific criteria reference text in the form.

Thanks in advance for any help!!!

View 7 Replies View Related

Need Little Help On Querying Two Tables

Aug 10, 2005

Just joined this forum and posting my very first thread.. ^^

I need to create query to pull data from two different tables. This should be really easy query for most of you. Once someone help me set it up, I can do the modifying.

If you look at the image, there are two tables. For each of pf_id (which is unique ID), I need to know the dept_name which is on other table. I know two tables can be linked with dept_id but I don't know how to create query. If you can help me , I would greatly appreciate it~


Result should be like below.

pf_id, dept_id, dept_name
___________________________
wh08051bh-Navy, 01-001, washed hat
wh60516bh-white, 01-001, washed hat
.
.
.
ru11072bh-white_with_navy, 01-002, roll up bucket hat
.
.
dh03871bh-Dk._Blue, 01-003, denim hats
.
.

<img src="http://www.highdots.com/forums/attachment.php?attachmentid=183">
http://www.highdots.com/forums/attachment.php?attachmentid=183

View 2 Replies View Related

Querying For An Astricks

Oct 11, 2005

Is there a way of querying for an astricks? Some data in one of my tables has data that looks like this "A*" or "B*" or "C*", but most of the records are just "A" or "B" or "C"...I just need a query that I can pull out those records. Is there a way of doing this in a query?

Thanks

View 1 Replies View Related

Querying Using Value From A Subform

Nov 4, 2005

I need to take a value from a subform and use it in a query but I don't seem to be able to come up with the correct criteria in the query....

I have so far tried:
[Forms].[frm_Matching].[SubMatching].[txtSingleFixedPayer]
[Forms].[frm_Matching].[SubMatching].[form].[txtSingleFixedPayer]

[Forms].[sub_Matching_single].[txtSingleFixedPayer]
[Forms].[sub_Matching_single].[form].[txtSingleFixedPayer]

[Forms].[frm_matching].[sub_matching_single].[txtsinglefixedpayer]
[Forms].[frm_matching].[sub_matching_single].[Form].[txtsinglefixedpayer]

And probably a load of other versions of the above.... can anyone help out possibly?

The following pulls back the value in code but isn't accepted in the query as a valid criteria:

Forms("frm_Matching").[SubMatching].[Form].[txtSingleFixedPayer]

View 1 Replies View Related

Anti-querying?

Jun 2, 2006

OK,
I work for a political party. I work with voter history information. Normally, I am doing queries in order to bring up particular voters, and eliminate others.

Example - the basic table I work with contains the names, addresses, affilitations, and voting histories of everyone in my county. I normally query to bring up voters of a particular party, or people who voted in a particular election or number of elections or both. I more or less sort voters out, but in a positive manner, by creating tables with voters who did a particular thing.

For example: out of all the voters, I just want Democrats who voted in two of the past three primaries. I would then get a table that contained just those voters and no others.

Today, though, I was asked to create a table that would exclude voters based on their behavior, exluding voters who did a particular thing but showing everyone else.

Example, I have a request for all of the voters in the county, except those who voted in the 2004 and 2002 primaries. I know how to create a table with those voters and no others, but I don't know how to query for everyone but those voters. Can anyone help?

View 2 Replies View Related

Querying On MONTH Alone!

Sep 18, 2006

Hi there,

I am getting really wound up with this. It should be so simple!

I need to create a query on a field (actualdateofvisit) and group it by the month to give me a count of all those visits (hence the catchy field name) which occurred each month since the beginning of the project. In other words I want to see:

Month Count of Visit
Jan 43
Feb 54
Mar 78

and so on.

I have tried everything I can think of but cannot work out how to do this? I need to do it in a query NOT a report as I want to port it to Crystal reports to display there.

I am think of something like:

field: Actual Date of vist
table: visits
total: Group By
Criteria: "Month"

Can anyone help me?

Thanks and Regards
Mark

View 5 Replies View Related

Querying A Time Value?

Dec 4, 2006

Hi all,

I have a query that is supposed to get a time value from a field and enter a string into a new field based on the time it gets.

this is what i have. Its my VERY first query ever and so i'm not sure of the syntax. I doesnt work though so i'm assuming something must be wrong. Can anyone help?

iif((hour([request date])>12)and(minute([request date])>30)), "After 12:30", "Before 12:30"

Cheers,
Spinkung. :)

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved