T
Tom Lewis
After updating a subform in datasheet view, I need to
requery the subform's parent's parent (2 levels up), but I
need to keep the active control on the subform selected,
(ideally without any flicker from screen updates).
When the requery takes place the parent gets the focus, so
I need to use code to return the focus to the control that
had it in the subform prior to the requery. I set a
variable to the ActiveControl in the subform prior to the
requery of the parent, but when I try to use this variable
to set the focus I get the error:
Run-time error '2465':
Microsoft Office Access can't find the
field 'SelectControl' referred to in your expression.
Apparently the variable name, not its value, is being used
when trying to specify the control that should get the
focus. My syntax must be off somewhere, but I'm not sure
how to do this correctly.
My code follows:
Private Sub Form_AfterUpdate()
Dim SelectControl As Control
Set SelectControl = Me.ActiveControl
Me.Requery
Parent.Parent.Requery
Me.SelectControl.SetFocus
End Sub
Any help or suggestions for alternative approaches would
be most welcome. Thanks in advance,
Tom
requery the subform's parent's parent (2 levels up), but I
need to keep the active control on the subform selected,
(ideally without any flicker from screen updates).
When the requery takes place the parent gets the focus, so
I need to use code to return the focus to the control that
had it in the subform prior to the requery. I set a
variable to the ActiveControl in the subform prior to the
requery of the parent, but when I try to use this variable
to set the focus I get the error:
Run-time error '2465':
Microsoft Office Access can't find the
field 'SelectControl' referred to in your expression.
Apparently the variable name, not its value, is being used
when trying to specify the control that should get the
focus. My syntax must be off somewhere, but I'm not sure
how to do this correctly.
My code follows:
Private Sub Form_AfterUpdate()
Dim SelectControl As Control
Set SelectControl = Me.ActiveControl
Me.Requery
Parent.Parent.Requery
Me.SelectControl.SetFocus
End Sub
Any help or suggestions for alternative approaches would
be most welcome. Thanks in advance,
Tom