Solved

Clear Highlight from Listbox Selection

Posted on 2007-03-28
13
1,317 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
  • 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
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)

 
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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

856 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