DoCmd.GoToRecord , , acNewRec to Sub Form

S

Silvio

This is what I have for cmdAddRecord:

Me!Mysub!EstAdmin = Me.TxEstAdmin
Me!Mysub!EstBuilding = Me.TxEstBuilding
DoCmd.GoToRecord , , acNewRec

I need to refer this last line to the sub form (MySub) and not the main
form. How?

Thanks!
 
A

Allen Browne

You need to get the focus into the subform so that the final line works
there and not in the main form.

That's a 2 step process:
1. Make the subform control the active control of the main form.
2. Set focus to something in the subform.

Try:
Me.MySub.SetFocus
Me.MySub.Form!ExtAdmin.SetFocus
RunCommand acCmdRecordsGotoNew

Not sure if you intend the 2 text boxes to be populated after you go to the
new record? If before, explicitly save those changes before you try to move
record, i.e.:
Me.MySub.Form.Dirty = False
 
Top