473,418 Members | 1,926 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,418 software developers and data experts.

Open form to last record

I am assuming this is an easy fix but I want to open a form from a switchboard button. I also want the form to automatically open to the last record of that form.

Any ideas on how I can accomplish this?

Thanks!
Adam
Apr 9 '09 #1

✓ answered by missinglinq

Highlite and Copy this code:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.  DoCmd.RunCommand acCmdRecordsGoToLast
  3. End Sub
  4.  
In Design View for the form to be opened, on the menu
  1. Goto View - Code
  2. Paste the code in
  3. Goto View - Object
  4. Run the form

6 64954
RuralGuy
375 Expert 256MB
Always? If so, put this in the OnLoad Event Procedure:
DoCmd.RunCommand acCmdRecordsGoToLast
Apr 9 '09 #2
RuralGuy-

Thanks for the script but I am a novice at Access...I am not sure where to place the OnLoad command? I want to click a button from my Switchboard...where would you recommend me placing the script?

And yes, this would be all the time that the form would open to the last record.

Thanks!
Apr 9 '09 #3
missinglinq
3,532 Expert 2GB
Highlite and Copy this code:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.  DoCmd.RunCommand acCmdRecordsGoToLast
  3. End Sub
  4.  
In Design View for the form to be opened, on the menu
  1. Goto View - Code
  2. Paste the code in
  3. Goto View - Object
  4. Run the form
Apr 9 '09 #4
PERFECT!!!

Thanks for your help!
Apr 9 '09 #5
missinglinq
3,532 Expert 2GB
Glad we could help!

Linq ;0)>
Apr 9 '09 #6
@missinglinq
Easy way to fix it
When a form's data entry property is set to yes, it always opens to an empty recordset. As you add records they accumulate and you can scroll forward and back within that set of records. When you close and reopen the form, the form opens to an empty recordset again.

If you want the second form to show the most recent ("last" has no meaning in database terms since record order is fluid), you need to set the form's data entry property to No and either reference the newest record specifically or do what I said earlier and create a query that sorts the recordset in descending order by date/time entered or autonumber.
Feb 23 '17 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Dalan | last post by:
I presume that using an open recordset method is the preferred method of accomplishing what I'm trying to do. Of course, if there are other options that would work, feel free to share them. I...
2
by: Arnold | last post by:
Hey there, I just put the following code: DoCmd.GoToRecord , , acLast in the On Open event of my form, which has 2 subforms. The following error message appears when the form now opens: ...
3
by: BLUE WATER | last post by:
Hi, I have managed to simplify my problem but can't seem to get this to work. I want to open up a form from a click event of another form, but not only open the form when the button is pressed...
2
by: Bill Hand | last post by:
Is it possible to open a form from table and have it access a given record? I want to be able to query all baseball cards with the last name Jones and have it open a table. In each record of...
2
by: Paul T. Rong | last post by:
Who can tell me how to write vba, if I want to open the last record of "order" form where the customer name is Larry King, in other words, records with the customer name "Larry King" are many, but...
4
by: sara | last post by:
I am learning with a simple application/form. I am ok - enter customer name, list box of customers, select a customer, see the items for that customer. The items form has customer ID and Name...
4
by: piscogirl | last post by:
Hi all, Here's my case: I have a form: Event Form and a subform: AttendanceSubForm The user selects a name (from a Person Table) on the subform to register for the event. If the name is...
9
by: mtgrizzly52 | last post by:
Hi all, I've looked for an answer for this in lots of books, online in several discussion groups and have not found the answer which I feel may be very simple. What I want to do is have a...
1
by: sentry1 | last post by:
So, I'm not quite sure how to make this happen: When I open a form, I want it to go to the last record, I.E. if I have 49 records in the underlying table, I want the form to open at record # 49. ...
1
by: Coll | last post by:
Hi - I'm trying to figure out how to append a record to a table and then open a form and display that record. My thought was to use the autonum primary key field (recordnum) and display the highest...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
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,...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.