Form freezes with Combo Recordset

  • Thread starter Thread starter Stephen
  • Start date Start date
S

Stephen

I have a form with a few subforms. On the top of the form, there is a simple
combo box which when the user selects teh vale, teh form moves to the
selected record in the table.

Code is as follows:

Private Sub SearchField_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[AssociationID] = " & Str(Nz(Me![SearchField], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark

End Sub

The problem I have is that when the users selects the Association for teh
first time, it works great. However, when teh user selects anothe
Association, the form seems to go through an endless search and then
locks/freezes the form. The form flickers slightly as if there is some
endless looop/update process going on the background.

Is there a need to set teh recordset to null or something like that after
the search is completed? Any suggestions on what to do and how to address
this?

-Stephen
 
i don't know if this would cause your problem, but you
shouldn't need the If statement, or the Nz function either
i think.

Private Sub SearchField_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
' use the next line if the value is numeric
rs.FindFirst "[AssociationID] = " & Me!SearchField
' or, use the next line if the value is text
rs.FindFirst "[AssociationID] = '" & Me!SearchField
& "'"
Me.Bookmark = rs.Bookmark

End Sub

that's the same code (with the single appropriate line for
rs.FindFirst) that you would get from the ComboBox Wizard.
if you have trouble with it, suggest you delete your combo
box and add a new one using the wizard to write the code
for you.

hth
 
Back
Top