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

how to reset a listbox after selection

I have a form that allows the user to selct items from a listbox and combo
box.

how do I reset them ready for the next set of entries. I thought I would
have a clear button.

regards in advance.

Peter
Nov 13 '05 #1
8 25287
For a combo box or a single-selection list box, just set the value to Null,
e.g.:
Me.MyCombo = Null

To clear a multi-select list box

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

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Peter Bailey" <pe*********@andaluz.fsbusiness.co.uk> wrote in message
news:ci**********@news7.svr.pol.co.uk...
I have a form that allows the user to selct items from a listbox and combo
box.

how do I reset them ready for the next set of entries. I thought I would
have a clear button.

Nov 13 '05 #2
thanks Allen, it must be early in australia.
"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message
news:41***********************@per-qv1-newsreader-01.iinet.net.au...
For a combo box or a single-selection list box, just set the value to Null, e.g.:
Me.MyCombo = Null

To clear a multi-select list box

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

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Peter Bailey" <pe*********@andaluz.fsbusiness.co.uk> wrote in message
news:ci**********@news7.svr.pol.co.uk...
I have a form that allows the user to selct items from a listbox and combo box.

how do I reset them ready for the next set of entries. I thought I would
have a clear button.


Nov 13 '05 #3
Me.ListDOS.Enabled = True

ClearList (me.ListDOS)

When I call the function it gives error 424 object required, not sure why as
I think I am passing the listbox ok.
"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message
news:41***********************@per-qv1-newsreader-01.iinet.net.au...
For a combo box or a single-selection list box, just set the value to Null, e.g.:
Me.MyCombo = Null

To clear a multi-select list box

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

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Peter Bailey" <pe*********@andaluz.fsbusiness.co.uk> wrote in message
news:ci**********@news7.svr.pol.co.uk...
I have a form that allows the user to selct items from a listbox and combo box.

how do I reset them ready for the next set of entries. I thought I would
have a clear button.


Nov 13 '05 #4
Which line gives the error?

Does the code compile? (Compile on Debug menu)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Peter Bailey" <pe*********@andaluz.fsbusiness.co.uk> wrote in message
news:ci**********@news5.svr.pol.co.uk...
Me.ListDOS.Enabled = True

ClearList (me.ListDOS)

When I call the function it gives error 424 object required, not sure why
as
I think I am passing the listbox ok.
"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message
news:41***********************@per-qv1-newsreader-01.iinet.net.au...
For a combo box or a single-selection list box, just set the value to

Null,
e.g.:
Me.MyCombo = Null

To clear a multi-select list box

Function ClearList(lst As ListBox) As Boolean
If lst.MultiSelect = 0 Then
lst = Null
Else
For Each varItem In lst.ItemsSelected
lst.Selected(varItem) = False
Next
End If
End Function
"Peter Bailey" <pe*********@andaluz.fsbusiness.co.uk> wrote in message
news:ci**********@news7.svr.pol.co.uk...
>I have a form that allows the user to selct items from a listbox and combo > box.
>
> how do I reset them ready for the next set of entries. I thought I
> would
> have a clear button.

Nov 13 '05 #5
Allen Browne wrote:
Which line gives the error?

Does the code compile? (Compile on Debug menu)


I would think that if the person declared varItem it would work.
Nov 13 '05 #6
It fails on this :ClearList (me.ListDOS)

I couldnt compile as you said as it was picking up a mountain of other
things. (I didnt design the database I am just adding a function to it)
regards
Peter
"Salad" <oi*@vinegar.com> wrote in message
news:Nd*****************@newsread1.news.pas.earthl ink.net...
Allen Browne wrote:
Which line gives the error?

Does the code compile? (Compile on Debug menu)


I would think that if the person declared varItem it would work.

Nov 13 '05 #7
Does it compile?

As Salad pointed out, add this line to the top of the procedure:
Dim varItem As Variant

Then try:
Call ClearList (me.ListDOS)
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Peter Bailey" <pe*********@andaluz.fsbusiness.co.uk> wrote in message
news:ci**********@news8.svr.pol.co.uk...
It fails on this :ClearList (me.ListDOS)

I couldnt compile as you said as it was picking up a mountain of other
things. (I didnt design the database I am just adding a function to it)
regards
Peter
"Salad" <oi*@vinegar.com> wrote in message
news:Nd*****************@newsread1.news.pas.earthl ink.net...
Allen Browne wrote:
> Which line gives the error?
>
> Does the code compile? (Compile on Debug menu)
>


I would think that if the person declared varItem it would work.

Nov 13 '05 #8
Thanks to everybody who assisted adding the variable fixed the problem.

regards
Peter
"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message
news:41***********************@per-qv1-newsreader-01.iinet.net.au...
Does it compile?

As Salad pointed out, add this line to the top of the procedure:
Dim varItem As Variant

Then try:
Call ClearList (me.ListDOS)
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Peter Bailey" <pe*********@andaluz.fsbusiness.co.uk> wrote in message
news:ci**********@news8.svr.pol.co.uk...
It fails on this :ClearList (me.ListDOS)

I couldnt compile as you said as it was picking up a mountain of other
things. (I didnt design the database I am just adding a function to it)
regards
Peter
"Salad" <oi*@vinegar.com> wrote in message
news:Nd*****************@newsread1.news.pas.earthl ink.net...
Allen Browne wrote:

> Which line gives the error?
>
> Does the code compile? (Compile on Debug menu)
>

I would think that if the person declared varItem it would work.


Nov 13 '05 #9

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

Similar topics

2
by: (Pete Cresswell) | last post by:
Seems like I've been here before, but can't find anyting in Google. I've got two list boxes on a form. Seems to me like the inactive ListBox's selection rectangle should be something like...
6
by: Dan Bass | last post by:
If you look at explorer, right clicking on a file, first selects the file, then throws up the context menu relating to that selection. With a Windows ListBox control and a simple context menu,...
6
by: Alpha | last post by:
I have a listbox with datasource from a dataview. When a user selects a different item in a combobox then I need to refresh the listbox to the appropriate listing based on that combobox's selected...
6
by: Chris Leuty | last post by:
I am populating a multiselect Listbox from a dataset, with the content of the listbox filled by one table, and the selections determined from another table. So far, I have been keeping the dataset...
5
by: Lie | last post by:
Hi all, I have problem in getting selectedindex of multiple listbox selection in a datagrid. I have a listbox with multiple selection mode inside datagrid. In Edit mode, I need to get back all...
0
by: Sanjin | last post by:
I have populated listbox with data from the datatable. I binded SelectedValue to the another datatable - i.e. selection result (with VS 20005 wizard). Selection result datatable has...
3
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...
9
by: zdrakec | last post by:
Hello all: Clearly, I'm not getting it! Here is the scenario: On a web page, I have two list boxen and a text box. The first listbox is populated at page load time (if it is not a postback)....
4
by: kimiraikkonen | last post by:
Hi, I have a odd but a known question about listbox. I know listbox control can provide multi-select, multi-extendend selections. But i wonder if this selection type belongs to them or it has...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...
0
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...
0
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,...
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.