473,662 Members | 2,551 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to reset listbox & cb box to first item after clearing

I have a function courtesy of the newsgroup that clears the list box. I
would like to now set the listbox back to its initial state where you can
see the first item in the list. The same goes for a combo box I am not sure
after clearing how to get it back to show the first item.

Regards
Peter

Function ClearList(lst As ListBox) As Boolean
If lst.MultiSelect = 0 Then
lst = Null
Else
For Each varItem In lst.ItemsSelect ed
lst.Selected(va rItem) = False
Next
End If
End Function
Nov 13 '05 #1
2 7960
Look in Access VBA Help for ItemData. Without looking it up, I would guess
the code would read...

Me!lstX = Me!lstX.ItemDat a(0)

Larry Linson
Microsoft Access MVP

"Peter Bailey" <pe*********@an daluz.fsbusines s.co.uk> wrote in message
news:ci******** **@newsg3.svr.p ol.co.uk...
I have a function courtesy of the newsgroup that clears the list box. I
would like to now set the listbox back to its initial state where you can
see the first item in the list. The same goes for a combo box I am not sure after clearing how to get it back to show the first item.

Regards
Peter

Function ClearList(lst As ListBox) As Boolean
If lst.MultiSelect = 0 Then
lst = Null
Else
For Each varItem In lst.ItemsSelect ed
lst.Selected(va rItem) = False
Next
End If
End Function

Nov 13 '05 #2
stupid me tried this;
Me!lstX.ItemDat a(0)

thanks Larry

"Larry Linson" <bo*****@localh ost.not> wrote in message
news:2dI4d.9925 $Bg5.4815@trndd c07...
Look in Access VBA Help for ItemData. Without looking it up, I would guess
the code would read...

Me!lstX = Me!lstX.ItemDat a(0)

Larry Linson
Microsoft Access MVP

"Peter Bailey" <pe*********@an daluz.fsbusines s.co.uk> wrote in message
news:ci******** **@newsg3.svr.p ol.co.uk...
I have a function courtesy of the newsgroup that clears the list box. I
would like to now set the listbox back to its initial state where you can see the first item in the list. The same goes for a combo box I am not

sure
after clearing how to get it back to show the first item.

Regards
Peter

Function ClearList(lst As ListBox) As Boolean
If lst.MultiSelect = 0 Then
lst = Null
Else
For Each varItem In lst.ItemsSelect ed
lst.Selected(va rItem) = False
Next
End If
End Function


Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
4639
by: google | last post by:
Hello, I am trying to create a listbox that users can select multiple entries on. I want Access to put each on of those selections in a different row on a particular table. This table will also include the primary key of the parent form of the form that has the listbox. Here is the code that I have. Right now it will put all of the selections from the listbox into one row. Private Sub Category_Click()
8
1485
by: gv | last post by:
Ok, Hi all, new to asp.net. Simple question with web forms I have a Dropdownlist and a listbox, I want to click on and item in the dropdownlist and show items in listbox. that simple I have this: I have two items in Dropdownlist. The Reportlist doesn't show
2
3835
by: tangokilo | last post by:
Hello and thanks for your help, I have the following Listbox created in VisualStudio 2003 designer, desiring to select multiple entries from that list: ------------------------------- ListBoxUser.Location = New System.Drawing.Point(16, 240) ListBoxUser.Name = "ListBoxUser" ListBoxUser.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended ListBoxUser.Size = New System.Drawing.Size(136, 147) ListBoxUser.TabIndex = 6
7
4529
by: Dave | last post by:
Hi all, After unsuccessfully trying to make my own dual listbox control out of arraylists, I decided to look for a 3rd party control. I've looked for over a week now and can't find anything but ASP.Net stuff when I need a Windows Form control. I've seen dual listbox populators in countless Windows applications, and have seen them run very fast, so I figured this would be extremely popular. Here's how it should work:
3
2024
by: Mark Lauser | last post by:
I have a Windows app (.net v1.1) and I am dragging from a list box. The first drag works fine, but all subsequent drags continue to pull the first item that was dragged. It appears that MouseDown does not cause the SelectedItem to change (even though the highlighted item changes). So, if I click down on a non-highlighted item and drag it off the list box, the new item looks selected, but is not really the SelectedItem. I see that the...
3
2626
by: Alec MacLean | last post by:
Hi, I have a couple of win forms where I am editing values that are stored in a SQL database. I'm using the listbox control to hold the data object each form interacts with. Each object is defined by my own classes. On the first form, I use an approach to reduce the number of database calls. This essentially consists of :
3
3619
by: kaosyeti via AccessMonster.com | last post by:
hey... i have an unbound multiselect listbox on a form that i want to use to populate text boxes on that form. so if a user selects the 3rd item in a list of 20, how can i have that item show up in a text box? then, how can i have a second selected item show up in a different text box, without affecting the 1st one? (lboxOptions, txtboxOptions0, txtboxOptions1, etc..) -- Greg Message posted via AccessMonster.com
3
1996
by: Angel Blue01 | last post by:
I have a form with a binding navigator that draws from a database via drag-and-drop-created controls. I'm filling a listbox with the results of a query. The listbox contains data related to the record that the user is viewing but cannot be databound because other events and user input are needed when the user selects an item from the listbox. Each time the user clicks the binding navigator to move to the next record I have this: <code>
15
2361
by: Doogie | last post by:
I have a .net app that a user currently enters a number in a text box, hits a button and a data call is executed. She wants the ability to enter in multiple numbers (up to 100). So to make things look better visually for that, I created a listbox under the text box. She enters the number in the text box, clicks another button I added and the number is stored in the list box. Then my plan was to grab all those numbers from the list box...
0
8432
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
8344
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8764
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...
0
8633
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7367
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...
0
4180
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...
0
4347
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2762
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1752
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.