Solved

Listbox value property will not reset to null

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
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…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

747 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

9 Experts available now in Live!

Get 1:1 Help Now