Solved

Listbox value property will not reset to null

Posted on 2007-03-23
4
256 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Familiarize people with the process of utilizing SQL Server stored procedures 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 Micr…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

734 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