Dropdown listbox fires AfterUpdate on focus

  • Thread starter Thread starter rsmith
  • Start date Start date
R

rsmith

Hi All,
I have a form where there is a command button. On the clicked event
for this button, I set some parameters and then set focus on a dropdown
list box. In debug, as soon as the SetFocus is done, the code
immediately jumps into the AfterUpdate procedure for this very same
dropdown. This is causing problems because the AfterUpdate procedure
is calling a function, and ending up with null values.
Any suggestions, or tips on why this is happening?
TIA, Randy
 
Do you have any code, such as in the GotFocus event of the combo box, that
sets the value of the combo box? Have you tried deleting the combo box and
creating a new one in case the current one is corrupted?

I just tried it here to make sure there wasn't a bug and it didn't happen.
 
Wayne,
Just prior to calling the SetFocus event, I do a requery on the list
box. You see, the drop down list box can contain as many as 100,000
rows, and to help the user, we've set up these command buttons to
narrow down the number of rows. So, we have command buttons for "A" to
"D", "E" to "H", etc.
 
By the way, it seemed to work perfectly under Access 2000, but this
problem is now happening in Access 2003 after conversion.
Thank you so much for responding!!!
Randy
 
I suspect that when you requery, you have reset the value from the previous
selection to Null and the AfterUpdate is firing. You may need to trap this
and abort the event. One option would be to Exit Sub if the value of the
combo box is Null. Another would be to set a form level "flag" variable to
True in the code that does the Requery and SetFocus and check the value of
this variable in the AfterUpdate event, if it is True, then reset it to
False and Exit Sub.
 

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

Back
Top