strange listbox behavior after update of listbox value

selahlynch

Registered User.
Local time
Tomorrow, 01:54
Joined
Jan 3, 2010
Messages
63
I have a form that is bound to a table. One can select a record using combo boxes or using a list box. Each time I change the record I want both my combo boxes and my list box to reflect this change.

Things work properly when I select a record by using a combo box. However when I select a record by using my list box, the item I selected becomes de-highlighted an instant after I select it. I don't understand why it does this.

Here is my code...

Code:
Private Sub NameCombo_AfterUpdate()
    If Not IsNull([NameCombo]) Then Me.Recordset.FindFirst "[AccessID] = " & [NameCombo]
End Sub

Private Sub NumberCombo_AfterUpdate()
    If Not IsNull([NumberCombo]) Then Me.Recordset.FindFirst "[AccessID] = " & [NumberCombo]
End Sub

Private Sub EmployeeList_AfterUpdate()
    If Not IsNull([EmployeeList]) Then Me.Recordset.FindFirst "[AccessID] = " & [EmployeeList]
End Sub

Private Sub Form_Current()
    Call RefreshImage
    EditToggle = False
    [NameCombo] = [AccessID]
    [NumberCombo] = [AccessID]

    'this line is where my listbox selection becomes de-highlighted
    [EmployeeList] = [AccessID]

End Sub
 
Code:
   [COLOR=red] Call RefreshImage[/COLOR]
    EditToggle = False
    [NameCombo] = [AccessID]
    [NumberCombo] = [AccessID]

    'this line is where my listbox selection becomes de-highlighted
    [COLOR=red][EmployeeList] = [AccessID][/COLOR]
check your above code

what is code for Call RefreshImage
check this also which has no meanig [EmployeeList] = [AccessID]
 
Call RefreshImage is calling a subroutine that I created.

[EmployeeList], [NameCombo] and [NumberCombo] are references to my list box and my combo boxes.

[AccessID] is the primary key field of the recordsource of my form.

Hope that makes it a little bit clearer.
 
Hey again,

I isolated my problem with a much simpler database example.

I attached a database. Go to form1 and compare the behavior when you change records using the listbox... vs when you change records using the navigation bar. See how the value you select in the listbox becomes de-highlighted.

Also, here is my code in it's entirety:
Code:
Option Compare Database

Private Sub Form_Current()
    
[ListBox2] = [Field1]
End Sub

Private Sub ListBox2_AfterUpdate()
    Me.Recordset.FindFirst " Field1 = '" & 
[ListBox2] & "'"
End Sub
 

Attachments

?? When you click on an item in the list box, your selection stays highlighted ??

I'm NOT talking about if you select using the navigation arrows at the bottom of the form window. In this case I agree it works fine.

I'm using Access 2007. How about you?
 
It's your form's ON CURRENT code that is the culprit.

Also, why are you doing a FindFirst evertime an item is selected?
 
That's correct, it stays hilighted, whether I select it using the nav buttons or by clicking on the listbox.

I'm running v2003. I'll look around and see if this is a bug in 2007.
 
It really isn't a bug. You're searching the Recordset not the RecordsetClone.
 
Thanks missinglinq... good to know that it works properly in Access 2003.

vbaInet, I am using a FindFirst to select a record based on my listbox. In my database I am sometimes selecting a record using a listbox, and sometimes selecting using a combo box. After I navigate to a new record, I want both controls to be updated to reflect the current selected record. If you look at my original post the intent might be more clear.
 
There is a bug in 2007 wherein when you leave a combobox it becomes transparent. Many problems with comboboxes are also present in listboxes, and this may be a manifestation of that.

What service pack do you have installed? This link

http://support.microsoft.com/kb/974995

has a hotfix to download that addresses the above problem and may help you. You have to have SP2 installed to install the hotfix, but the page has a download link for that as well.

If it works let us know, for future reference.
 
Thanks missinglinq... good to know that it works properly in Access 2003.

vbaInet, I am using a FindFirst to select a record based on my listbox. In my database I am sometimes selecting a record using a listbox, and sometimes selecting using a combo box. After I navigate to a new record, I want both controls to be updated to reflect the current selected record. If you look at my original post the intent might be more clear.
Ah alright. I thought your combo box was bound. Just opened your db :)
 
I have Service Pack 3. I'll let you know if I have any luck with that hotfix.
 

Users who are viewing this thread

Back
Top Bottom