ALthough I first found the problem I'll describe in a complex database, to troubleshoot (and try to confirm it was not a user problem) I then started a very simple DB with one form. Add a list box with three values entered directly ((All), (Non Blank), (Blank)). Set the multi-select option to NONE.
I have one control button on the form that runs the following single line of code to reset the default selection to the first option:
Me!lbDescription.Selected(0) = True
This works as you would expect. I then added a ONOPEN event to the form to call the above sub to reset the selection to the default I also added in some msg boxes to see the progress. So I have:
Private Sub Command2_Click()
MsgBox "Run Default"
Me.lbDescription.Selected(0) = True
MsgBox "End Run Default"
End Sub
Private Sub Form_Open(Cancel As Integer)
MsgBox "Form Open"
Command2_Click
MsgBox "end Form Open"
End Sub
Open the form and, although it opens up, you cannot select any entry, control etc. Sometimes after a long period of time it will come alive. All the msg boxes show up however.
If you change the multiselect option to either simple or extended, the form opens just fine. If you comment out the On Open event, the form will open and you can run the reset to default code without a problem.
I have tried all sorts of variations on this (using functions instead of subs etc) and it always come back to the form freezing if the list box is set for no multiselect.
Although there are certainly ways to work around this (use combo box for example), I would rather keep the look and feel of the actual form consistent as there are many list boxes on my actual DB (although only one does not allow multi-select).
Any suggestions would be very much appreciated.
Thanks.
I have one control button on the form that runs the following single line of code to reset the default selection to the first option:
Me!lbDescription.Selected(0) = True
This works as you would expect. I then added a ONOPEN event to the form to call the above sub to reset the selection to the default I also added in some msg boxes to see the progress. So I have:
Private Sub Command2_Click()
MsgBox "Run Default"
Me.lbDescription.Selected(0) = True
MsgBox "End Run Default"
End Sub
Private Sub Form_Open(Cancel As Integer)
MsgBox "Form Open"
Command2_Click
MsgBox "end Form Open"
End Sub
Open the form and, although it opens up, you cannot select any entry, control etc. Sometimes after a long period of time it will come alive. All the msg boxes show up however.
If you change the multiselect option to either simple or extended, the form opens just fine. If you comment out the On Open event, the form will open and you can run the reset to default code without a problem.
I have tried all sorts of variations on this (using functions instead of subs etc) and it always come back to the form freezing if the list box is set for no multiselect.
Although there are certainly ways to work around this (use combo box for example), I would rather keep the look and feel of the actual form consistent as there are many list boxes on my actual DB (although only one does not allow multi-select).
Any suggestions would be very much appreciated.
Thanks.