473,765 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Prompt selection to the last record in the list box

56 New Member
Does anyone know how to write a code to promt the selection at the last record in the list box?. I have this code below in the "On Click" event, when user click on the code, it close a form, requery the list box, but then I would like the selection to be prompted at the last record.

Expand|Select|Wrap|Line Numbers
  1. DoCmd.Close acForm, "frmReview" 
  2. [Forms]![frmPatientAccount]![lstPtReview].Requery
  3. 'woud like to add here a line of code to prompt selection of the listbox to the last record.
  4.  
thanks!
Oct 12 '08 #1
8 3923
missinglinq
3,532 Recognized Expert Specialist
Maybe something like:

Me.lstPtReview = Me.lstPtReview. ItemData(Me.lst PtReview.ListCo unt - 1)

Linq ;0)>
Oct 12 '08 #2
NeoPa
32,572 Recognized Expert Moderator MVP
Indeed. Setting the record of a ListBox or ComboBox is done, rather bizarrely, by setting it to the value of one of them (as Linq's code does).
Oct 12 '08 #3
bluemoon9
56 New Member
Linq,
thanks alot. It works so well.

bluemoon
Oct 12 '08 #4
bluemoon9
56 New Member
Hi,
I've tried to change from -1 to 0 to prompt record to the first added record in the list, but it did not work, anybody can help?

<code>
[Forms]![frmPatientAccou nt]![lstPtReview] = [Forms]![frmPatientAccou nt]![lstPtReview].ItemData([Forms]![frmPatientAccou nt]![lstPtReview].ListCount(0))

</code>

what I would like to do is prompt the listbox to the newly added record since my list is sorted from Z to A, so the new record will be the first record in the list.

Thanks!
Bluemoon
Mar 23 '09 #5
ADezii
8,834 Recognized Expert Expert
@bluemoon9
Assuming your List Box is named lstTest, to Select the 'Last' entry:
Expand|Select|Wrap|Line Numbers
  1. Me![lstTest].Selected(Me![lstTest].ListCount - 1) = True
Mar 23 '09 #6
bluemoon9
56 New Member
Hi,
Thanks for your help.
That's was my previous question. Now, the user would like to move it to the First record instead of the last, I've tried to change from -1 to 0 or 1, but nothing works well. I've tried other way such as GoToRecord,,acF irst, but nothing happens.

Any idea? Thanks alot!

bluemoon
Mar 23 '09 #7
DonRayner
489 Recognized Expert Contributor
@bluemoon9

Since you don't know the location of the last record you have to get the number from the count of records listed in the listbox.
Expand|Select|Wrap|Line Numbers
  1. (Me![lstTest].ListCount - 1)
But when trying to move to the first record you already know where the record is, it's the first one.
Expand|Select|Wrap|Line Numbers
  1. Me![lstTest].Selected(1) = True
Just be careful if it's a multiselect listbox as this won't deselect any previously selected items.
Mar 23 '09 #8
bluemoon9
56 New Member
Hi,
my listbox is not a mutiselection. It's a single select list box. so it worked perfectly.
Thank you for your help.

bluemoon.
Mar 23 '09 #9

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

Similar topics

7
19315
by: Petesman | last post by:
I am trying to make a prompt that will ask the user for some input... If I just use var input = prompt("dafa") everything works fine but the box is put in the top left corner of the window. I need it to be centered so... I was doing some research on the net (never really used much JavaScript before) and was reading the only way to do this is by making your own custom prompt. In my attempts of doing so I came up with this code below. The...
1
3488
by: P51D | last post by:
I have a listbox in the headere of a form with the details below. Once the form's open it works properly, allowing me to select a record and see the related details. On opening the form, however, I get a prompt for a parameter (logically enough) because no record is selected. How can I automatically have it open to the first record in the recordset?
8
2582
by: Galina | last post by:
Hello I have 6 dependent list boxes on my ASP page:  Faculty;  Lecturer;  Course;  Course occurrence;  Group;  Week commencing date. When faculty is selected, lists of lecturers and courses are populated. When course is selected, lists of occurrences, groups and
3
7888
by: J.P. Cummins | last post by:
In my ASP.NET application, I wish to have a page for administrators to edit items in a list. Preferably, I would like to use the javascript prompt for the 'rename' function, and a javascript alert box for the 'delete' function. When the user clicks 'rename', the javascript prompt asks for the new name. When the user clicks 'delete', a javascript alert asks the user if he really wants to delete that item. Here is an example of what my...
2
5491
by: Strasser | last post by:
Problem: Query record selection criteria reads Like & "*" BUT, then Access changes it to non-functioning Alike & "*" Any ideas? Thank you in advance. Strasser
1
3382
by: assgar | last post by:
Hi I was using a schroll bar to display multiple rows of dynamically created from database records. The scrolling was not displaying the data properly so I have decided to use pagination. The problem I am having is, if I select one item on page #1 and another on page #5 only the last item selected on page #5 is stored in the array. How can I store selections from multiple pages into one array?
13
8453
BigToe
by: BigToe | last post by:
Hello, if anyone out there can shed light on the fact that when a last name is selected in a combo box, and that name is shared by more than one person, why access is displaying the first record in the list of like names. (i.e. when choosing 'zach smith' , 'andy smith's record will be shown. I assume that it's sorting by first names when last names are the same that doesn't explain why it always shows the record of the first person amoung a...
7
14518
by: robtyketto | last post by:
Greetings, I'm slowly building up code to do the following:- Display TWO selection option boxes (cascading). If the FIRST selection option box changes then reload the jsp using onchange event (not changing the option box value on relaod i.e. not re-running the SQL query). ONLY on initial entry should the form FIRST selection option box should be populated using JDBC SQL.
0
9568
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10156
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10007
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9951
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8831
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7375
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5275
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3531
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2805
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.