Wrong event triggered on listbox_AfterUpdate

P

Patti

I have a listbox that displays a list of clients (LB1). I have
another listbox (LB2) that displays a list of phone calls made to the
client selected in LB1. I want to auto-select the first row in LB2
after the user selects a client in LB1. I can get all this to work
just fine. The problem is that when I click LB2, the LB1_AfterUpdate
is triggered. HUH??? I have verified that this is really happening
by putting in debug.print "proc_name" into my procedures. When the
user selects a client in LB1, the following code snippet is run, which
populates LB2 and selects the first row:

strSQL = "SQL statement here"

Me.lstCallLog.RowSource = strSQL
Set db = CurrentDb()
Set rst = db.OpenRecordset(strSQL)

If rst.RecordCount > 0 Then
If lngCallID = 0 Then
Me.lstCallLog.Selected(0) = True 'Problem code
lngCallID = Me.lstCallLog.Column(0) 'Problem code
Else
With lstCallLog
.Visible = False
For intI = 0 To .ListCount
.Selected(intI) = True
If .Column(0) = lngCallID Then Exit For
Next intI
.Visible = True
End With

End If

Me.txtCallLogCaller.Requery
Me.txtCallLogDate.Requery
Me.txtCallLogNote.Requery

Else
lngCallID = 0
End If



I have narrowed down the problem to the "Problem code" indicated
above. But why is this triggering the LB1_AfterUpdate event??? How
can I auto-select the first row in LB2?

Many thanks,

Patti
 
T

TC

Maybe the problem code (or some other part of LB1's event code) fires an LB2
event, which executes code, which does something that causes the LB1
afterupdate to fire?

HTH,
TC
 
G

Graham R Seach

Patti,

It sounds like LB1 has corrupted.

1. Keep LB1's code, but delete LB1 from the form.
2. Close the form, compact and close the database.
3. Then re-open the database and add a new instance of LB1.
5. In the Properties dialog, re-link all its event procedures.

This should resolve the problem.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
 
P

Patti

Thanks, Graham, for your suggestion. I have used the 'delete,
compact, rebuild' technique before with great success. Unfortunately,
this time it didn't work, and just for good measure I deleted LB2 as
well as LB1. I will try deleting the whole form and recreating it -
not a pleasant prospect as I have lots of code in there. If that
doesn't work I will post another message. Many thanks, again.

Patti
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top