ACCESS '97: Why?: Form Freezes up when setting ListBox default [RESOLVED]
Esteemed Forum Participants and Lurkers:
===============================
ACCESS '97
Why is it that when I include the following code, it freezes up my panel?
I have some buttons, checkboxes, and a list box that can be operated normally, except that EVERYTHING freezes up when the following is UNcommented:
Code:
Private Sub Form_Open(Cancel As Integer)
'Controls("cmd_DateRange").Selected(0) = True
End Sub
Note that the Form can still be moved and closed, and the proper item in the list box is selected, but all of the controls on the form are frozen.
Re: ACCESS '97: Why?: Form Freezes up when setting ListBox default ???
Are you trying to set the focus to this control when the form opens.. and what control is it as it named like a command button
Re: ACCESS '97: Why?: Form Freezes up when setting ListBox default ???
Danny ...
Regardless of the name, it is indeed a ListBox (I've renamed it now to "box_DateRange").
No, I'm not doing anything with the Focus ... I'm just trying to open the Form with the topmost item in this ListBox selected as the default. The user should then be able to select a different date from the list if so desired.
The selection process works ... when the Form opens the correct list item is highlighted (Item 0, 1, or 2 - I've tried it with all 3), but the form is frozen.
If I do NOT select a default in the ListBox, the form works fine and I can select any of the 3 items, operate the CheckBoxes, or operate the buttons.
Re: ACCESS '97: Why?: Form Freezes up when setting ListBox default ???
the code you need is
VB Code:
box_DateRange.Value = box_DateRange.ItemData(0)
Re: ACCESS '97: Why?: Form Freezes up when setting ListBox default ???
Danny ...
I don't know how you figured that one out, but it works GREAT!
Thanks again for your gracious assistance.
Re: ACCESS '97: Why?: Form Freezes up when setting ListBox default [RESOLVED]
Simple,
ItemData refers to the list of information inside the listbox
The list box is 0 bound with -1 set for no selection.. All you needed to do was set the value (i.e List Item) to be the first item in the ItemData..