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 8 25457
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.ItemsSelect ed
lst.Selected(va rItem) = 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*********@an daluz.fsbusines s.co.uk> wrote in message
news:ci******** **@news7.svr.po l.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.
thanks Allen, it must be early in australia.
"Allen Browne" <Al*********@Se eSig.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.ItemsSelect ed lst.Selected(va rItem) = 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*********@an daluz.fsbusines s.co.uk> wrote in message news:ci******** **@news7.svr.po l.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.
Me.ListDOS.Enab led = 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*********@Se eSig.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.ItemsSelect ed lst.Selected(va rItem) = 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*********@an daluz.fsbusines s.co.uk> wrote in message news:ci******** **@news7.svr.po l.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.
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*********@an daluz.fsbusines s.co.uk> wrote in message
news:ci******** **@news5.svr.po l.co.uk... Me.ListDOS.Enab led = 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*********@Se eSig.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.ItemsSelect ed lst.Selected(va rItem) = False Next End If End Function
"Peter Bailey" <pe*********@an daluz.fsbusines s.co.uk> wrote in message news:ci******** **@news7.svr.po l.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.
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.
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.co m> wrote in message
news:Nd******** *********@newsr ead1.news.pas.e arthlink.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.
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*********@an daluz.fsbusines s.co.uk> wrote in message
news:ci******** **@news8.svr.po l.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.co m> wrote in message news:Nd******** *********@newsr ead1.news.pas.e arthlink.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.
Thanks to everybody who assisted adding the variable fixed the problem.
regards
Peter
"Allen Browne" <Al*********@Se eSig.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*********@an daluz.fsbusines s.co.uk> wrote in message news:ci******** **@news8.svr.po l.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.co m> wrote in message news:Nd******** *********@newsr ead1.news.pas.e arthlink.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.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 gray...otherwise, the user sees two ListBoxes, both with black selection
rectangles - and the user does not visually know which one he is "in". This
becomes relevant if we have a keyboard-type user - they want to hit "Enter" and
have something...
|
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, the default
behaviour seems to display the context menu on the listbox, but there is no
selection.
Now I know that explorer's using a listview, and that the context menu acts
differently if you click on open space (no selection), but can I...
|
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 value which is included
in the listbox's filtering statement.
Is the only way to do this is to dispose the dataview and then create a new
one and then bind it to the listbox? Is there a better way than this?
Thanks, Alpha
|
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 a denormalized mirror of the
database, but I'm not having much luck getting the selection logic down (I
haven't found a 'hook' where I can access the listbox object as an object to
set the listitem's selected property before it gets rendered)..
...
|
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 selected items of that listbox and display
it.
can anyone help?
Thanks
| |
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 one column with type Int32.
|
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 :
|
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). This listbox
has AutoPostback = True. When the user selects an item from this list,
the second listbox is populated with more items relevant to this
selection. I am using an SQLDataSource web control for this. These
items are headers. I want, when...
|
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 another
tecnique.
As you may know, in softwares like Windows Media Player or Winamp
playlist has a listbox and it can be selected in 2 types. First type
refers to player's own selection and second selection type can be done
by user to look for...
|
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...
|
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,...
| |
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...
|
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...
|
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...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |