We help IT Professionals succeed at work.

After Requery do not reset Tab Order

jacobtdad
jacobtdad asked
on
I  need to requery after updating a field without the tab order reset.  I am using the code below but it keeps erroring out.  Each Record in the subform has a unique Detail_ID and when the Error_Count_Audit_Type gets focus, the requery works fine but the tab resets to the first field in this record.  After the code executes, I get a Runtime error  "Engine does not recognize 'Error_count_Audit_Type2' as a valid field name...I am lost  please help

Private Sub Error_Count_Audit_Type_GotFocus()
  Dim lngID As Long
   
    lngID = Detail_ID.Value
   
    'force calculations ...
    Me.Parent.Requery

    'navigate subform to the record you were working on ...
    Me.Recordset.FindFirst "Error_Count_Audit_Type" & lngID

    'now reset the focus ....

End Sub
Comment
Watch Question

DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Application Developer
Top Expert 2007

Commented:

Try this First
Me.Recordset.FindFirst "[Error_Count_Audit_Type] = " & lngID

mx
Database Developer
Commented:
You're absolutely right that a requery would result in that navigation to the first row (not exactly "resetting the tab order", but I think I understand what you mean).

There's nothing wrong with what you're attempting - other than the syntax of the FindFirst expression.
Surely if the field value you're holding as having the ID (PK) of the current row is stored in lngID, then that same field must be the FindFirst criteria.
i.e.
Me.Recordset.FindFirst "Detail_ID = " & lngID

You can take it a bit further, switch off screen painting and even make sure that the rows positioning is the same (i.e. so that the selected row is in the relative/absolute position it was previously.  There's an example of doing that on Stephen Lebans website - and also in one of my examples, but I can't think which one at this moment ;-)

Cheers.
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Application Developer
Top Expert 2007

Commented:
Is Error_Count_Audit_Type the Name of a Field (not a text box) in the underlying Table or Query of the Form ?

Also, this would be the typical usage ...

Me.RecordsetClone.FindFirst "[Error_Count_Audit_Type] = " & lngID
Me.BookMark = Me.RecordsetClone.Bookmark

Author

Commented:
This worked Great!