Solved

Listbox value property will not reset to null

Posted on 2007-03-23
4
253 Views
Last Modified: 2013-11-28
What I'm doing is slightly complicated, but I'll explain as best I can.  I have a listbox that's populating with a recordset based on the selection of an option frame.  If a user clicks on the first item in the option frame, the list box may populate with 3 records.  We'll say these records have Values 1, 2, and 3.  If the user then selects the first record (with value 1), a text box populates with the information for that record.  The problem comes in if the user changes the Option frame selection.  If he then picks a different option, the list box may populate with a null recordset which is fine.  If I run a listcount against the lsitbox, it comes back with 0 which is correct.  The problem is, the Value property of the listbox is still set to 1 (or whatever the LAST value was).  It will not resort back to an empty or null value.  Is there any way to force this property back?  Thanks!
0
Comment
Question by:CyprexxDev
  • 2
4 Comments
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 75 total points
ID: 18783355
in the click event of the option box

dim j
with me.listboxname
         for each j in .itemsselected
              .selected(j)=false
         next

end with
0
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 425 total points
ID: 18783367
Have you tried setting the .VAlue property to Null when the user selects a new option

Me.Listbox.Value = Null

Bigger question: Why would it matter? Are you running code in another module/proc which looks at that value? If not, then I'm not sure why it would make a difference. FWIW, I've always tested the value of a listbox like this:


If Me.Listbox.Column(0) = "some value" Then


0
 
LVL 1

Author Comment

by:CyprexxDev
ID: 18783446
Capricorn,
I've tried that.  The problem is, if you ser the selected propery to false for every item in the lsitbox, it will not allow you to select anything after that point.  What happens is I can click on a row after that runs, but the selection will flash on and off and the OnClick event for the ListBox control will not run at all.

LSMConsulting,
I tried your solution and it worked.   I had actually thought about this, but for some reason I kept thinking the Value property was read-only, so I never even tried it.  I guess I should have tried anyway.  And yes, I'm running code in a stored procedure that pulls the value of the list box at many different points in time.  I want to make sure this value is null if nothing is selected so the SP does not return anything otherwise my textbox populates with data from the last selected value.

I'm going to assign 75 points to Capricorn since this solution SHOULD work in my opinion and it was a good idea regardless.  LSM's was easier - I was just dumb...  but it's what actually fixed my problem.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 18783462
<The problem is, if you ser the selected propery to false for every item in the lsitbox, it will not allow you to select anything after that point>

you will place the clodes in the click event or after update of the option frame as
i mentioned in my post NOT in the CLICK event of the list box
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Launch app from Access custom ribbon 8 33
Can not open the Access Help ? 3 53
date criteria to pull up records for the last 3 months 39 42
aggregate query? 20 50
In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question