473,387 Members | 1,897 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,387 software developers and data experts.

Prompt selection to the last record in the list box

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 3881
missinglinq
3,532 Expert 2GB
Maybe something like:

Me.lstPtReview = Me.lstPtReview.ItemData(Me.lstPtReview.ListCount - 1)

Linq ;0)>
Oct 12 '08 #2
NeoPa
32,556 Expert Mod 16PB
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
Linq,
thanks alot. It works so well.

bluemoon
Oct 12 '08 #4
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]![frmPatientAccount]![lstPtReview] = [Forms]![frmPatientAccount]![lstPtReview].ItemData([Forms]![frmPatientAccount]![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 Expert 8TB
@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
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,,acFirst, but nothing happens.

Any idea? Thanks alot!

bluemoon
Mar 23 '09 #7
DonRayner
489 Expert 256MB
@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
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
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...
1
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,...
8
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...
3
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...
2
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
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...
13
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...
7
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...

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.