Can't set focus to main form after subform requery

  • Thread starter Thread starter Jason
  • Start date Start date
J

Jason

Hello all,

I have an Access 2003 ADP main form/sub form. The main form is bound
to an Invoice table and has an unbound text box name txtAddItem. The
subform has an sql statement for a record source that shows the
related line items to the invoice. If a user types in an ItemID into
the box txtAddItem it inserts a new record into the line items table
via a stored procedure that is executed in VBA code. Now after that I
requery the subform so it shows the newly inserted record.

All this works great, my problem is that the requery leaves the focus
in the subform and no matter what I do I can not move the focus back
to txtAddItem in the main form. Below is a snippit of the code that
does the requery and attempts to change the focus. The code is in the
main form's class module.

Private Sub txtAddNewItem_AfterUpdate()
Me.dbo_tblInvoiceLineItemsSubform.Requery
Me.txtAddNewItem = ""
Me.txtAddNewItem.SetFocus
end sub

Can anyone guide me on how to move the focus back to the main form
after the the requery of the subform?

Thanks,

Jason
 
I don't think performing the requery in general causes the focus to move.
I suspect that you have event handling code on the subform that is changing
the focus.
Try commenting out your sobforms proc and see if it still happens.
If it stop, then figure out another way to code up the subform proc.
Otherwise, I thik your stuck (unless you want to put a refocus into a
timer - hack hack)
 
Back
Top