Solved

Listbox value property will not reset to null

Posted on 2007-03-23
4
252 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 119

Assisted Solution

by:Rey Obrero
Rey Obrero 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 119

Expert Comment

by:Rey Obrero
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

863 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now