Go Back   Access World Forums > Microsoft Access Discussion > Modules & VBA

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 05-25-2010, 10:10 AM   #1
Rx_
Nothing In Moderation
 
Rx_'s Avatar
 
Join Date: Oct 2009
Location: Denver, Colorado
Posts: 2,803
Thanks: 636
Thanked 341 Times in 311 Posts
Rx_ has a spectacular aura about Rx_ has a spectacular aura about Rx_ has a spectacular aura about
Exclamation highlight top record in list box - after a delete

Assume: Form tied to one single table
The form and list box have records for a single customer
Current record in form matches listbox record.

Delete button successfully deletes current record

Question:
After checking to see that the list box has at least 1 record left:

Automate selecting the top item in the listbox and clicking on it.
(code from clicking on a list box updates and does lots of fun things on the form)

Rx_ is offline   Reply With Quote
Old 05-25-2010, 10:11 AM   #2
Rx_
Nothing In Moderation
 
Rx_'s Avatar
 
Join Date: Oct 2009
Location: Denver, Colorado
Posts: 2,803
Thanks: 636
Thanked 341 Times in 311 Posts
Rx_ has a spectacular aura about Rx_ has a spectacular aura about Rx_ has a spectacular aura about
Smile Re: highlight top record in list box - after a delete

May have found the solution:
Question: is the ListBox 0 based or 1 based - i.e. Selected(0) or (1)
Tried it - found out that 0 picks the top record.
Added 4 records, deleted all the way down to 1.


' lst_FedAPDID name of list box
If Me.lst_FedAPDID.ListCount >= 0 Then
lst_FedAPDID.SetFocus
lst_FedAPDID.Requery
Me.lst_FedAPDID.Selected(1) = True ' this does the trick
Call lst_FedAPDID_AfterUpdate ' runs some cool code
Call lst_FedAPDID_Click ' refreshes bottom part of form
Else
' guess it is time to figure out what to do if No records are left

end if

Last edited by Rx_; 05-25-2010 at 10:19 AM. Reason: hit enter too soon
Rx_ is offline   Reply With Quote
Reply

Tags
click , select top record , vba

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
List Box quandary BrettM Forms 2 12-14-2008 05:10 AM
Delete record deletes other records DazJWood Forms 2 05-12-2006 12:15 PM
[SOLVED] How do I issue items from a multi-level inventory? ltl Forms 5 01-27-2004 12:32 PM
List Box Values as Query parm for a Report Opengrave Reports 2 07-03-2002 10:29 AM
Problem closing a form with a combo box linked to a list box. Essendon Forms 1 04-10-2002 02:37 AM




All times are GMT -8. The time now is 10:43 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World