MSAccess returning null value until selected row clicked twice

Posted on 2013-09-03
Medium Priority
Last Modified: 2013-09-07
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.
Question by:hertzgordman
  • 3
  • 3
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 39462525
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?

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

Author Comment

ID: 39463324
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.
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 39463796
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...
Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.


Author Comment

ID: 39464317
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.
LVL 74

Accepted Solution

Jeffrey Coachman earned 2000 total points
ID: 39464413
<I am thinking its an issue related to a corrupted form or index>
Try the usual:
- Run the compact/repair utility
- decompile the database (http://www.fmsinc.com/MicrosoftAccess/Performance/Decompile.asp)
- Create a blank new db, and import all the objects

Sometimes you can also try replacing the listbox, ...but sometimes you have to bite the bullet and recreate the form...

Author Comment

ID: 39464749
Thanks Boag will try what you suggest...

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Sometimes MS breaks things just for fun... In Access 2003, only the maximum allowable SQL string length could cause problems as you built a recordset. Now, when using string data in a WHERE clause, the 'identifier' maximum is 128 characters. So, …
When we develop an application in Ms Access 2016 we should also try to protect the queries, macros and table links. I know I may not have a permanent solution but for novice users, they will not manage to break your application. Below is the detail …
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…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

607 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