Link to home
Start Free TrialLog in
Avatar of hertzgordman
hertzgordmanFlag for Canada

asked on

MSAccess returning null value until selected row clicked twice

Have a bound listbox.

When I click on the first row I am not able to return the value selected unless I click a second time.

When I bind a textbox to the listbox I can also see the value showing only on the second click.
Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

You did not post any info on:
If the listbosx is set to Multiselect?
How many columns the listbox has?
What code you are using now?
...ect

I typically avoid the onclick even and instead try to use the "AfterUpdate" event

This code works fine for me:

Private Sub Yourlistbox_AfterUpdate()
    MsgBox Me.Yourlistbox
End Sub
Avatar of hertzgordman

ASKER

The listbox is not set to MultiSelect.

In the afterupdate event I am running this piece of code:

MyRecordID = Nz(MyListBox.column(0))

This issue is that when you first click into the the listbox you can see the first row highlighted.  Yet MyListBox.Column(0) returns null.

When you then click the same row ago MyListBox.Colomn(0) now returns the expected value.
Well I don't know the full scope of your app (the entire code, properties, ...settings, ...ect)...

These things being said, ...this simple example woks just fine for me...
Database125.mdb
Thanks Boag will have look.  I am thinking its an issue related to a corrupted form or index. I will see if I can post a db to reproduce the error.
ASKER CERTIFIED SOLUTION
Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks Boag will try what you suggest...