Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old March 18th, 2008, 05:34 AM
Authorized User
Join Date: Feb 2008
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to hewstone999
Default Get last record and display in an Text Box

I have a Text Box called: VNo , and a table called: DocControl.

The Table contains this information

GFD v0.1 09/03/2008
GFD v0.2 11/03/2008
GFD v0.3 12/03/2008
TRD v0.4 13/03/2008
GFD v0.5 14/03/2008

I want the Text Box to display the last value in the Version Column, which in this case is "v0.5"

Any help thanks?

Old March 18th, 2008, 06:48 AM
Friend of Wrox
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts

What is it about the "last" record that makes it the last, in this case?

Is there a numeric PK that you can take the MAX() of, or are you going by the date? Or do you want it to figure out the latest version number?

You could use: SELECT MAX(Date) As MaxDate, Version FROM DocControl GROUP BY Version ORDER BY MAX(Date) DESC

Big problem here is the use of a reserved word for a column name. Your query may have a problem with "Date." In that case use "DocControl.Date" instead.

SELECT MAX(DocControl.Date) As MaxDate, DocControl.Version
FROM DocControl
GROUP BY Version

Did that help?


Look it up at: http://wrox.books24x7.com

Similar Threads
Thread Thread Starter Forum Replies Last Post
Count in combo box(display results in text box) mboyisis Access 4 April 4th, 2008 07:08 AM
Reset text box value on new record aware Access 3 October 24th, 2005 02:13 PM
record the time a text box is updated techsp Access 2 August 2nd, 2005 09:51 AM
Numeric Display in Text Box Tallon Wolle Pro VB 6 1 December 5th, 2003 05:11 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.