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

Unselect a value in a List Box

84
I have several forms that use list boxes. These list boxes are used to pass information to command line. The operator is not required to select an item from each box. See below

ListBox1 - (contains Op dates)
ListBox2 - (contains Customer Names)
ListBox3 - (Contains File Types)

COMMAND BUTTON CODE
Private Sub Command239_Click()
On Error GoTo Err_Command239_Click

Dim stAppName As String

stAppName = "c:\Commands.Bat " & "Op_Date=" & Me!ListBox1 & "Cust_Name=" & Me!ListBox2 & "FILE_TYPE=" & Me!ListBox3
Call Shell(stAppName, 3)

Exit_Command239_Click:
Exit Sub

Err_Command239_Click:
MsgBox Err.DESCRIPTION
Resume Exit_Command239_Click

End Sub

On the form if the operator selects one of the items from the list box they cannot unselect it. is there a way to un-select a list box value without closing the form or forcing the operator to select a blank field in the List?
Apr 29 '07 #1
6 38224
nico5038
3,080 Expert 2GB
You can use:

Me!ListBox1 = ""

Personally I prefer however to use a datasheet subform with a Checkbox to have one or multiple rows selected.
Then the query only needs to JOIN with the table and test for the checkbox field to be true.

Nic;o)
Apr 29 '07 #2
ADezii
8,834 Expert 8TB
I have several forms that use list boxes. These list boxes are used to pass information to command line. The operator is not required to select an item from each box. See below

ListBox1 - (contains Op dates)
ListBox2 - (contains Customer Names)
ListBox3 - (Contains File Types)

COMMAND BUTTON CODE
Private Sub Command239_Click()
On Error GoTo Err_Command239_Click

Dim stAppName As String

stAppName = "c:\Commands.Bat " & "Op_Date=" & Me!ListBox1 & "Cust_Name=" & Me!ListBox2 & "FILE_TYPE=" & Me!ListBox3
Call Shell(stAppName, 3)

Exit_Command239_Click:
Exit Sub

Err_Command239_Click:
MsgBox Err.DESCRIPTION
Resume Exit_Command239_Click

End Sub

On the form if the operator selects one of the items from the list box they cannot unselect it. is there a way to un-select a list box value without closing the form or forcing the operator to select a blank field in the List?
Setting the ListIndex Property of a List Box to -1 will effective de-select all those entries that were previously selected as in:
Expand|Select|Wrap|Line Numbers
  1. Me![lstTest].SetFocus
  2. Me![lstTest].ListIndex = -1
Apr 30 '07 #3
sesling
84
Please let me clarify the situation. On the form, lets say the operator has selected Op Date, Customer Name and File Type from the list boxes. Before launching the command button, they realize that they did not mean to select file type. How would they un-select that option before launching the command button?
Apr 30 '07 #4
nico5038
3,080 Expert 2GB
You'll have to add a [Reset] button with the command:
Me!Listbox1 = ""
for the first listbox, etc.

Nic;o)
Apr 30 '07 #5
sesling
84
You'll have to add a [Reset] button with the command:
Me!Listbox1 = ""
for the first listbox, etc.

Nic;o)
That worked great. THX
May 1 '07 #6
nico5038
3,080 Expert 2GB
Glad I could help, success with your application !

Nic;o)
May 1 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Ed Jay | last post by:
I use window.document.form1.myCheckbox.checked=false; to uncheck (reset) several checkboxes. What is an equivalent for resetting a set of interrelated radio boxes? -- Ed Jay (remove M to...
3
by: Stefan Mueller | last post by:
I've an input box <input type = "text" name = "MyInput" value = ""> and a selection <select name = "MySelection" size = "1"> <option value = "1">Entry 1 <option value = "2">Entry 2 </select>...
1
by: mikev | last post by:
Hi all I have a listbox which is 5 rows high. There are 5 list items. The first one is selected. I wish to click on a button and have the selection focus on the listbox removed. Removed,...
2
by: Stefan Mueller | last post by:
I've a ListView in ReportMode with MultiSelect = False. If the user enters a number I select the appropriate item in the ListView. If the used enters a number which is not in the ListView I'd...
1
by: =?Utf-8?B?anVsaW8=?= | last post by:
i have a listbox w/ single select mode. Can a user unselect an item by clicking on it? How is it implemented? Thanks
3
by: Joe Cool | last post by:
I have a ListBox on a form than has some items. The select mode is one item only. I select one, it is selected and hightlighted. I then click somewhere in the listbox not on any item, in the clear...
1
by: mishasoft | last post by:
Hi all, I have a HTML multiple select (ListBox) control: <select id="mySelect" multiple> <option>Apple</option> <option>Orange</option> <option>Pineapple</option> ...
1
by: rbr | last post by:
I have two listboxes on an asp.net web control (ascx). I want them to act non-mutually-exclusive. In other words, if an item in one listbox is selected, I want the other to be clear. The problem...
4
by: kashif73 | last post by:
Hi , I have a combobox in my form. If the user select some option from the combobox, it subsequently populate Listboxes (5 in all) on my form. This works fine. the annoying part is that in...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.