open nested subform to new blank record

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a tabbed form. trying to get nested subform on 3rd tab to open to new
blank record, and want user to have ability to scroll previous records.

this is my code:


Private Sub Form_Load()

Me!frmHospVisit!frmDailyData.SetFocus 'Set the focus to the nested
subForm
DoCmd.GoToRecord , , acNewRec 'Move to new record
[cboFindPatient].SetFocus 'Return to main form primary key field


End Sub


not opening frmDailyData to new record; still shows last record.

Thanks for the help.

patti
 
I have a tabbed form. trying to get nested subform on 3rd tab to open to new
blank record, and want user to have ability to scroll previous records.

this is my code:


Private Sub Form_Load()

Me!frmHospVisit!frmDailyData.SetFocus 'Set the focus to the nested
subForm
DoCmd.GoToRecord , , acNewRec 'Move to new record
[cboFindPatient].SetFocus 'Return to main form primary key field


End Sub

I think you'd be better using a Sub in the form's code module to move to the record. Depending on SetFocus to correctly
"point" your DoCmd argument is spotty, at best. Instead, include this in your subform's code:

Sub GoToNewRecord()
DoCmd.RunCommand acCmdRecordsGoToNew
End Sub

Now call this in your code above:

Me.NameOfYourSubformCONTROL.Form.GoToNewRecord

Note the syntax: NameOfYourSubformCONTROL is the name of the subform control, and may or may not be the name of the form
being used as subform ... in your case, it's not clear whether your subform is frmHospVisit or frmDailyData (or if those
are even valid names for the subform control).

Scott McDaniel
scott@takemeout_infotrakker.com
www.infotrakker.com
 
Back
Top