Listbox select in VBA causes form to not accept mouse clicks

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a listbox called RacesListBox on a form. In the form_open event
handler I have the following code:

Dim theSQL As String
theSQL = "SELECT * FROM Races"
Me!RacesListbox.RowSource = theSQL
Me!RacesListbox.Selected(3) = True

After the code executes, the form will no longer accept mouse clicks or any
user input. For example, I have a form close button with handler on the form,
and once the listbox selected statement is executed, clicking on the close
button has no effect.

If I comment out the statement
Me!RacesListbox.Selected(3) = True
then the form continues to work fine, but no listbox item is selected.

I'm confused!! Help!
 
The Open event of a form is usually too early to actually reference controls
on the form. Move your code to the form's Load event and see if that works
better for you.
 
That fixed it, thank you Ken. Much appreciated.

Ken Snell said:
The Open event of a form is usually too early to actually reference controls
on the form. Move your code to the form's Load event and see if that works
better for you.
 
Back
Top