Silly question: shifting focus with subforms

R

roger

( I KNOW i've done this before!)

I have 2 unbound subforms on a main form. When the user clicks a record on
subform A, i need to find the corosponding record in subform B.

This code:

Me.Parent.SetFocus
DoCmd.GoToControl "sbfrmB"
DoCmd.GoToControl "ItemID"
DoCmd.FindRecord me.ItemID

fails on the 1st line (I think) but actually errors on line 2 with "there is
no field named sbfrmB in the current record." which is because I havn't
managed to get the focus back to the main form.

what did I do wrong?
aha tia
 
K

Klatuu

First problem is:
Me.Parent.SetFocus
You cant set the focus to a form that has any controls on it capable of
receiving the focus. Also, the code you are using is not really good code to
use. I would suggest changing it to something like:

With Me.Parent.sbfrmB.RecordsetClone
.FindFirst "[ItemID] = " & Me.ItemID <<< Note Below
If Not .NoMatch Then
Me.Parent.sbfrmB.BookMark = .Bookmark
End If
End With

Note: I am not sure about this line because I don't know for sure what the
control bound to the ItemID is on sbfrmA. That is what you need to match on.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top