Refreshing the parent form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form and a subform both in datasheet view. When a record in the sub form gets changed a trigger runs in SQL server which changes a value in the parent form. I can refresh the parent form to show the new value (using Me.Parent.Refresh) but the problem is the focus moves to the the first row of the parent form instead of whatever cell in the subform the user clicked on.

Does anyone know a way round this? I've tried calling Me.Setfocus after refreshing the parent in an After Update event but I get an Invalid Expresion error message

Is there a way of setting focus to a particular cell in a datasheet, or working out the previous cell that lost focus

Thanks

Paul
 
Hi Paul, I had this problem as well - it took me forever to figure out something - although it's kind of dirt
Let's say for example updating the "total" field in my subform called "frmCRXSub", which updates by trigger the main form's total. I first get the form's current position, refresh the parent, then set focus back to my subform. With the position I already got, I can now return to that form.

Dim nPos As Intege

If Not IsNull(Me!SubID) The
nPos = Me.CurrentRecor
Me.Parent.Form.Refres
Forms!frmCRX!frmCRXSub.SetFocu
DoCmd.GoToRecord , , acGoTo, nPo
End If
 
Back
Top