SYNC Form to listbox



I have a listbox which can display all records or provide a limited
list based on a filter derived from an optiongroup. The code works
except in the one situation where the listbox filter is changed. The
problem
appears to be "Me.[List7].Selected(1) = True" which triggers
(sporadically) the click event for List7. The net effect is that when
I click the option button twice the form does update, but it should do
it in one click. The
first click correctly updates the listbox, the second click then
updates the form. The form updates as expected when you scroll
down the listbox entries. I would like to know how clicking on the
option button
will highlight the first item on the list and bring up the form's data
on just the first click.

Private Sub Frame33_Click()
Select Case Frame33
Case 0 'show all records
Me![List7].RowSource = "SELECT [projectnum], [projectname] FROM
projectnumqry; "
Case Else 'show limited (filtered) list
Me![List7].RowSource = "SELECT [projectnum], [projectname] FROM
projectnumqry where [type]=[frame33];"
End Select
[Text29] = [List7].ListCount - 1
DoCmd.GoToControl "[List7]"
Me.[List7].Selected(1) = True <=======problem line
End Sub
------------------------------------------
Private Sub List7_Click()
Rem Pulls-up the summary form information for the selected project
Me.Recordset.FindFirst "[projectnum] = " & Me.[List7]
Call setcontrols
End Sub

.


Quantcast