Subform SetFocus Problem. (1 Viewer)

Extra_Cover

Registered User.
Local time
Today, 19:12
Joined
Oct 21, 2008
Messages
71
Hi,

I have a problem returning to a record in a sub form. A user enters data in a subform Frm01FCData which has 12 periods - see attached screen dump. After a value has been entered the following After Update event is run to keep the PGroup value and the Product value so that after the requery the user will be returned to where they were.

Code:
Private Sub P1_AfterUpdate()

Dim Product As String
Dim PGroup As String

PGroup = Me.Parent!pgdes_type
Product = Me.stck_stkno

' Update
Forms!Frm01PGList.Form.Requery

'Return to Selected Product Group

Forms!Frm01PGList.pgdes_type.SetFocus
DoCmd.FindRecord PGroup
'Return to Selected Product
Forms!Frm01FCData.stck_stkno.SetFocus

DoCmd.FindRecord Product
Me.P2.SetFocus
End Sub
Having looked at the link given in another thread I'm sure this should work. However I get the error message 'Can't find form Fm01FCData'.

Where am I going wrong?
FCTool.jpg
 

JANR

Registered User.
Local time
Today, 20:12
Joined
Jan 21, 2009
Messages
1,623
Code:
'Return to Selected Product
Forms!Frm01FCData.[COLOR=red]Form.[/COLOR]stck_stkno.SetFocus

JR
 

Extra_Cover

Registered User.
Local time
Today, 19:12
Joined
Oct 21, 2008
Messages
71
Code:
'Return to Selected Product
Forms!Frm01FCData.[COLOR=red]Form.[/COLOR]stck_stkno.SetFocus
JR

Still get the same error message 'Can't find form Fm01FCData'.??
 

JANR

Registered User.
Local time
Today, 20:12
Joined
Jan 21, 2009
Messages
1,623
Is the SubformContainer Nameproperty Fm01FCData??

JR
 

Extra_Cover

Registered User.
Local time
Today, 19:12
Joined
Oct 21, 2008
Messages
71
Is the SubformContainer Nameproperty Fm01FCData??

JR

Yes. If I don't return the focus to the parent form then the code works fine to find the last product after the requery. This is fine if working on the first item in the main form - but if working on another item in the main form further down the list after the requery it returns to to the first item. It's like the subform isn't open?
 

JANR

Registered User.
Local time
Today, 20:12
Joined
Jan 21, 2009
Messages
1,623
I'm at a loss, could it be that it is the SetFocus that's the problem. You can manipulate the subform control, like set its backcolor etc.

JR
 

JANR

Registered User.
Local time
Today, 20:12
Joined
Jan 21, 2009
Messages
1,623
Found the solution, searching the forum helps. :)

The trick is to set the focus twice, first to the subform conteiner and then to the control.

Code:
Forms!Frm01FCData.SetFocus
Forms!Frm01FCData.Form.stck_stkno.SetFocus

JR
 

Extra_Cover

Registered User.
Local time
Today, 19:12
Joined
Oct 21, 2008
Messages
71
Thanks for input JR - finally managed to sort it. You need to reference the parent form so

Code:
Forms!Frm01PGList!Frm01FCData.SetFocus
Forms!Frm01PGList!Frm01FCData!stck_stkno.SetFocus
Works!!
 

Users who are viewing this thread

Top Bottom