jwcolby
jwcolby at colbyconsulting.com
Tue Dec 25 09:08:44 CST 2007
It just occurred to me that there is a much easier way to do this (assuming that you use bound forms, which this request implies). First of all, you need a date / time stamp column. The PKID is not necessarily autoincrement (in a generic solution), it may be a GUID or a random. But a date/time stamp captures the latest entered. So, create TWO subforms. One to do data entry. That takes the place of the unbound method that AD suggests. Then a display subform below that. the display subform uses a sort descending on the date / time stamp. Then simply do a requery on that subform in the afterupdate of the data entry subform. You might want to do a TOP 10 or TOP 100 to prevent pulling thousands of records for every requery assuming there are a ton out there. John W. Colby Colby Consulting www.ColbyConsulting.com -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of A.D.Tejpal Sent: Tuesday, December 25, 2007 12:05 AM To: Access Developers discussion and problem solving Subject: Re: [AccessD] The Command underlying the AZ and ZA buttons ontheAccess toolbar Arthur, There is no guarantee that the last added record will necessarily be at the extreme end of sort order. It would therefore be preferable to ensure that freshly added record occupies the top position, irrespective of its sort rank. My sample db named AddDataAtTop might be of interest to you. It is available at Rogers Access Library (other developers library). Link - http://www.rogersaccesslibrary.com/OtherLibraries.asp#Tejpal,A.D. The sample is in Access 2000 file format and a brief description is given below for ready reference. You could adapt the underlying approach suitably, for your specific needs. Best wishes, A.D.Tejpal ------------ Brief Description: (Sample Db - AddDataAtTop) ========================================== This database demonstrates three styles of data entry at top of a subform: (a) Continuous Form Display (Using Command Button) - Data is entered via unbound text boxes in subform header, using command button on the parent form. Freshly added Record is highlighted in green, while other recent records added in current session are shown in orange. (b) Datasheet Display (Using Command Button) - On clicking the command button on parent form, fresh blank record (highlighted in green) is presented at the top of subform for enabling data entry. Recent records added in current session are shown in orange. (c) Datasheet Display (Auto - No command button) - On opening the main form, user is presented with fresh blank record (highlighted in green) at the top of subform. As soon as data entry commences in this record, its back color changes to yellow, while another fresh blank record (in green) is offered at top. All other recent records added in current session are shown in orange. ========================================== ----- Original Message ----- From: Arthur Fuller To: Access Developers discussion and problem solving Sent: Tuesday, December 25, 2007 02:17 Subject: [AccessD] The Command underlying the AZ and ZA buttons on theAccess toolbar My client is giving me so much aggravation on this! She wants the detail records to show up most recent first, meaning that after a detail row is added, it automatically drifts to the top of the subform, rather than remaining on the bottom. This is easy enough to do, just by clicking the ZA button on the toolbar after adding the new record, but what is the VBA command constant that represents this command? I guess I'll try building a macro and see what code gets generated. If anyone already knows how to code this, and has nothing better to do on Christmas Eve, let me know. I can't recall ever building a macro in Access, but what the hell, I'll give it a shot. Well, I gave it a shot, and I have no idea what this weird interface is about. Excel macros are soooo much easier! I need to relocate that list of Access command things and give that a try instead. The client is adamant that she wants the most recent transactions on top, and I can see her point, since there could be hundreds per master record and they show the balance, which is the item of most immediate interest, and the transactions of immediate interest are those within the last few days to month, so that's why they should be on top not at the bottom. But I am having a most difficult time arranging this. Any advice greatfully appreciated. TIA. Arthur -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com