Can't Keep focus in Subform

  • Thread starter Thread starter Owen
  • Start date Start date
O

Owen

Hi,

I have a subfom on a main form and I am trying to add data from the main
form onto the subform. The code I have works, as far as adding the data, but
the cursor keeps going back to the main form after the procedure has run. I
cannot figure this one out and any help would be reatly appreciated. My code
is:

Private Sub REGWORKED_Exit(Cancel As Integer)
'Take WORKTICKETID and put it into WTLABORID

Dim strWTLABORID As String

Forms!WorkTicketAddfrm.SetFocus
Forms!WorkTicketAddfrm!WTID.SetFocus
strWTLABORID = Forms!WorkTicketAddfrm!WTID.Text

WTLABORID.SetFocus
WTLABORID.Text = strWTLABORID

OTWORKED.SetFocus
End Sub

TIA
Owen
 
Owen said:
I have a subfom on a main form and I am trying to add data from the main
form onto the subform. The code I have works, as far as adding the data, but
the cursor keeps going back to the main form after the procedure has run. I
cannot figure this one out and any help would be reatly appreciated. My code
is:

Private Sub REGWORKED_Exit(Cancel As Integer)
'Take WORKTICKETID and put it into WTLABORID

Dim strWTLABORID As String

Forms!WorkTicketAddfrm.SetFocus
Forms!WorkTicketAddfrm!WTID.SetFocus
strWTLABORID = Forms!WorkTicketAddfrm!WTID.Text

WTLABORID.SetFocus
WTLABORID.Text = strWTLABORID

OTWORKED.SetFocus
End Sub


Excuse me, but your VB is showing ;-)

In Access, the Text property is only used in limited and
fairly unusual scenarios. Use the Value (default) property
instead.

Since the Value property does not need the focus your code
can be shortend to:

Private Sub REGWORKED_Exit(Cancel As Integer)
Me.WTLABORID = Parent.WTID
End Sub
 
Back
Top