Solved Move to subform control after update errors

hullstorage

Registered User.
Local time
Today, 11:34
Joined
Jul 18, 2007
Messages
213
Hi all, a bit rusty as not used access in a while but decided to create new database so getting back to grips lol

anyway i have form called goodsinward and subform goodsinwarddetails

how do i move from field in form (after update) to field in subform ?

Ive tried these but getting error

Forms!GoodsInwardDetails_Subform.SetFocus
Forms!GoodsInwardDetails_Subform.Form!SuNumber.SetFocus
also tried

Forms!GoodsInwardDetails.SetFocus
Forms!GoodsInwardDetails.Form!SuNumber.SetFocus

also tried
Me!GoodsInwardDetails.SetFocus
Me!GoodsInwardDetails!SuNumber.SetFocus
 
Set focus to the subform container control first, then set focus to the control you want on the subform.

Personally, I would use the Me.SubformControl.SetFocus syntax if I was in the form itself.
 
so the subform is called "GoodsInwardDetails" and the field is called "SUNumber", how do i name these in focus?
is it GoodsInwardDetails_Subform or just GoodsINwardDetails?

Thanks
 
so the subform is called "GoodsInwardDetails" and the field is called "SUNumber", how do i name these in focus?
is it GoodsInwardDetails_Subform or just GoodsINwardDetails?

Thanks
If the name of the subform control (not the name of the form that it's holding) is GoodsInwardDetails, then:
Forms.GoodsInward.Form.GoodsInwardDetails.SetFocus
Forms.GoodsInward.Form.GoodsInwardDetails.Form.SUNumber.SetFocus
Or
Forms!GoodsInward.Form!GoodsInwardDetails.SetFocus
Forms!GoodsInward.Form!GoodsInwardDetails.Form!SUNumber.SetFocus
Or
Forms.Item("GoodsInward").Form.Controls.Item("GoodsInwardDetails").SetFocus
Forms.Item("GoodsInward").Form.Controls.Item("GoodsInwardDetails").Form.Controls.Item("SUNumber").SetFocus

If the subform control is named GoodsInwardDetails_Subform, then:
Forms.GoodsInward.Form.GoodsInwardDetails_Subform.SetFocus
Forms.GoodsInward.Form.GoodsInwardDetails_Subform.Form.SUNumber.SetFocus
Or
Forms!GoodsInward.Form!GoodsInwardDetails_Subform.SetFocus
Forms!GoodsInward.Form!GoodsInwardDetails_Subform.Form!SUNumber.SetFocus
Or
Forms.Item("GoodsInward").Form.Controls.Item("GoodsInwardDetails_Subform").SetFocus
Forms.Item("GoodsInward").Form.Controls.Item("GoodsInwardDetails_Subform").Form.Controls.Item("SUNumber").SetFocus

All of these are to be used from outside your main form, but can work from inside your main form as well. However, if you're gonna reference the subform from the main form, then use Me instead of Forms.FormName for simplicity. Should I post the Me variations?
 
Last edited:
still getting errors, ive renamed subform to GoodsInwardDetails and also attached copy of mockup if you would be so good to see whats wrong with it please
 

Attachments

yes i do but seems coding seems to have changed since i last used it on access 2013 😂😂
 
I renamed your subform control to contGoodsInwardDetails (e.g.the subform container), not the subform itself.
Then this works:
Code:
Private Sub RMA_NUMBER_AfterUpdate()

  Me.contGoodsInwardDetails.SetFocus
  Me.contGoodsInwardDetails.Form.SUNumber.SetFocus

End Sub
 

Attachments

ive renamed subform to GoodsInwardDetails
no, you haven't

1. suggest remove spaces for field and control names - it only adds confusion to what you need to use (square brackets or underlines)
2. coding has not changed

this works for me in your example app

GoodsInwardDetails_Subform.Form.SetFocus
GoodsInwardDetails_Subform.Form.SUNumber.SetFocus
 
no, you haven't

1. suggest remove spaces for field and control names - it only adds confusion to what you need to use (square brackets or underlines)
2. coding has not changed

this works for me in your example app

GoodsInwardDetails_Subform.Form.SetFocus
GoodsInwardDetails_Subform.Form.SUNumber.SetFocus
AHHH great thanks, i didnt even think of the nameing in the fields section.. cheers.. i did say i was rusty lol
 
Marked as solved, but to further clarify. You mentioned the subform control name had an underscore like GoodsInwardDetails_Subform, but it was actually a space, like GoodsInwardDetails Subform.

There was also an incorrectly copy-pasted instruction that was duplicated in the sample.

But this is the code that would have worked without changing control names, so you still have this option.
Code:
Private Sub RMA_NUMBER_AfterUpdate()
    Forms!GoodsInward.Form![GoodsInwardDetails Subform].SetFocus
    Forms!GoodsInward.Form![GoodsInwardDetails Subform].Form!SUNumber.SetFocus
End Sub
 

Users who are viewing this thread

Back
Top Bottom