Solved

Clear Highlight from Listbox Selection

Posted on 2007-03-28
13
1,338 Views
Last Modified: 2013-11-28
Hi There,
Product: MS ACCESS 2000
Process: FORM (CREATION)
Function: LISTBOX (CREATION)
Problem: MANAGING  VALUE "HIGHLIGHTING"
I am creating a form from scratch.
The first field is a listbox, lblCDTYPEREF, which selects a value from the underlying Table tblCDDESCR.
The result correctly displays the list of options from the Table.
When I click to select an item from the list the value is highlighted.
However, when I tab across to the next field the highlight remains on the listbox; it does not change.
What do I need to do (assumingly withing the listbox properties, AfterUpdate)  to remove the highlight once I tab across from the listbox field? Or is the field requiring a corresonding table field to apply the selection to?
(I'm creating this dummy form as a step to building the form slowly but surely.
Thanks very much.
djvbWarrior (Access Novice)
0
Comment
Question by:djvbwarrior
[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
  • 4
  • 3
  • 2
  • +1
13 Comments
 
LVL 5

Expert Comment

by:Atropa
ID: 18820602
ListBox1.Selected = ""

That should do the trick I hope.  let me know if it does not...a
0
 
LVL 34

Expert Comment

by:jefftwilley
ID: 18821398
How about in the after update event, you do something like so

With Me.MyListBox
    For I = 0 To .ListCount - 1
        .Selected(I) = False
    Next I
End With
0
 

Author Comment

by:djvbwarrior
ID: 18842398
Hi again,
With Jeffwilley's  suggestion:
With Me.MyListBox
    For I = 0 To .ListCount - 1
        .Selected(I) = False
    Next I
End With
This does not appear to have made a difference. I can make a selection, but the highlight remains when I tab to another field.

With Atropa's suggestion, the coding may require further clarification. Should it appear in the AfterUpdate property of the Listbox?
I have tried using it there, VB flags up an selected(IROW as Long) value requested.
Im confused now.
Thanks
Djvbwarrior
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 34

Expert Comment

by:jefftwilley
ID: 18842467
can you take a moment and paste in the event code you're using please?
J
0
 

Author Comment

by:djvbwarrior
ID: 18843809
Hi there jefftwilley:
Currently it looks like this, based on  what's been suggested earlier.
Apologies if I'd taken the earlier comments too literally:
Private Sub lboCDTYPEREF_AfterUpdate()
With Me.lboCDTYPEREF
    For I = 0 To .ListCount - 1
        lboCDTYPEREF.Selected(I) = False
    Next I
End With
Context:
The listbox lboCDTYPEREF displays a list of values contained in the table tblMUSICTYPE. The list is being displayed.
What I want to have happen is to select a value from lboCDTYPEREF and have that  populate a corresponding field in a subsequent table.
At the moment I can make a selection, and the selection is highlighted.
When I tab across the value remains highlighted.
I want the value from this field (i.e. lboCDTYPEREF ) to update a subsequent table and then when i tab from the box, for the highlighting to disappear and the list to return to the first value.
Trust this makes sense.
Should you need further clarification on table structure, etc please let me know.
Thanks
djvbwarrior
0
 
LVL 34

Accepted Solution

by:
jefftwilley earned 50 total points
ID: 18843912
Private Sub lboCDTYPEREF_AfterUpdate()
dim I as long
With Me.lboCDTYPEREF
    For I = 0 To .ListCount - 1
        .Selected(I) = False
    Next I
End With
end sub
0
 
LVL 5

Assisted Solution

by:Atropa
Atropa earned 50 total points
ID: 18844018
Put it in OnLostFocus
0
 
LVL 34

Expert Comment

by:jefftwilley
ID: 18844103
It shouldn't have to be put on Lost focus, because the only time anything will get highlighted is when it's "updated".
After Update should work fine.
J
0
 

Author Comment

by:djvbwarrior
ID: 18856197
Hi there,
Thanks for these updates.
I will apply and feed back as soon as possible.
DJ
0
 
LVL 61

Expert Comment

by:mbizup
ID: 19015047
The code works fine... however it does need to be in the lost focus (or some other) event.  In the AfterUpdate event, it will deselect the user's selections immediately, so the user never actually sees the selections highlighted.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
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 …
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

749 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