Problem with the event

Hi,
I have such event

Private Sub Fld_AfterUpdate()
    MsgBox Right(Me.Fld, 5)
End Sub

to the List box, within Access 2010 project. Upon that, I've selected one other option to that. I see nothing has been displayed. why?
LVL 11
HuaMinChenSystem managerAsked:
Who is Participating?
 
Gustav BrockConnect With a Mentor CIOCommented:
Sorry, missed it was a ListBox. Then the AfterUpdate event is your option.

It will work. If it doesn't, something else is going on. Try to recreate the listbox, or start with a new form where you create (from scratch) the ListBox.

/gustav
0
 
James ElliottManaging DirectorCommented:
Does the message box display?
0
 
HuaMinChenSystem managerAuthor Commented:
No. why?
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
Gustav BrockCIOCommented:
Because it doesn't update before you leave the field or record.

/gustav
0
 
HuaMinChenSystem managerAuthor Commented:
thanks. How to ensure that one other event can be fired, upon one change to the list, if "AfterUpdate" event is not the option to use?
0
 
James ElliottManaging DirectorCommented:
try the change event
0
 
HuaMinChenSystem managerAuthor Commented:
Sorry, I can only see the events attached, which are available to the List box
t826.png
0
 
Jeffrey CoachmanMIS LiasonCommented:
Private Sub Fld_AfterUpdate()
    MsgBox Right(Me.Fld, 5)
End Sub

Is "Fld" the actual name of the control?

From your property box screenshot, ...it looks like the name of the control is: "Identifier"...
screen?

So you might want to try something  like this:
Private Sub Identifier_AfterUpdate()
    MsgBox Right(Me.Identifier, 5)
End Sub
0
 
PatHartmanCommented:
Is there only a single column in the RowSource for the list?  It doesn't sound like it.

Me.YourListBox refers to the bound column of the RowSource which is the key field.  In most cases, this is a numeric identifier and is not the value that is displayed.  Since you are interested in the text value, you need to figure out what column that is.

To reference other columns of the RowSource, use the .Column() property.

MsgBox Right(Me.Identifier.Column(1), 5)

The columns of the RowSource are a zero based array so Column(0) is the first column, Column(1) is the second, etc.  So change my example as appropriate.
0
 
jkaiosIT DirectorCommented:
Try the Click event instead.

Private Sub Fld_Click()
    MsgBox "Item selected: " & Fld.value
End Sub

Open in new window

0
 
HuaMinChenSystem managerAuthor Commented:
Thanks all. I'll confirm to all suggestions given.
0
All Courses

From novice to tech pro — start learning today.