• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 382
  • Last Modified:

Access Querry Only Display Last Record

Experts:

I have a certain Query in my Access Database.

I only want this Query to display fields from the last record updated to it.  What’s the best way to make this happen?

Thanks.
0
mdstalla
Asked:
mdstalla
  • 5
  • 3
1 Solution
 
Eric ShermanAccountant/DeveloperCommented:
<<<I only want this Query to display fields from the last record updated to it.>>>

Do you mean last record added to the table???
0
 
Eric ShermanAccountant/DeveloperCommented:
If you are referring to the last record added and you have an ID field that uniquely identifies each record then ...

SELECT [tblYourTable].*
FROM [tblYourTable]
WHERE ((([tblYourTable].ID)=DMax("ID","[tblYourTable]")));

ET
0
 
mdstallaAuthor Commented:
ET:

Yes, I mean the last record added to a Table.  

The Table is called TblInterviewMain and the Unique ID is called InterviewID.  How would this code look now that you have that information?

Also, where do I place the code you provided?  Can you walk me through how to open up the appropriate VBA Code screen where I should drop this code?

Sorry—I'm a bit of an Access Rookie!

Thanks for your help.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Eric ShermanAccountant/DeveloperCommented:
The code I posted is not VBA ... It is the SQL for you query.

Just replace tblYourTable with your table name or better yet load up a sample of your database.  That will make it easier to work with.

ET
0
 
mdstallaAuthor Commented:
Your code needed a little adjusting, but I got it to work (that you for getting my 90% there).

 WHERE ((([tblYourTable].ID)=DMax("ID","[tblYourTable]")));

Needed to be changed to:

WHERE (((tblInterviewMain.[InterviewID])=DMax("InterviewID","[tblInterviewMain]")));

I've got another similar one for you... just let me know if you want me to close this out and open a new ticket:

Do you have an SQL code that will force my Query to display only the 1st (top) record that appears on it's list?

Note:  My Querry is already programed to order its list by 'which record received the last change/update to one of its fields.'
0
 
Eric ShermanAccountant/DeveloperCommented:
Yes, that would be a separate question.

<<<<<Your code needed a little adjusting, but I got it to work (that you for getting my 90% there).
  WHERE ((([tblYourTable].ID)=DMax("ID","[tblYourTable]")));
 Needed to be changed to:
 WHERE (((tblInterviewMain.[InterviewID])=DMax("InterviewID","[tblInterviewMain]")));>>>>>

Well ... I think my solution answered your question 100% since I have no way of knowing what the table and field names are.  They were not provided in you original question.  :-)

ET
0
 
mdstallaAuthor Commented:
Thanks for all of your help E!
0
 
Eric ShermanAccountant/DeveloperCommented:
Ok, glad it worked out for you.

ET
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now