Code: Select all
Forms!frmMainForm.Form!pgTwo.SetFocus
With Forms!frmMainForm!frmSubform
.SetFocus
RunCommand acCmdRecordsGoToNew
!first_name = "John"
!last_name = "Smith"
' saving should not really be necessary, but...
RunCommand acCmdSaveRecord
End With
The purpose is to track phases of plant growth through the year. The subform records the week and one of 12 growth phases. For the week I’m using, for example, 8.2 to mean the second week in August.
Instead of clicking the New Record button and typing in the week identifier for each plant, I want to click a button and have vba enter a new record for the current plant and populate the Week field with the week I'm currently recording. Then I can just add the growth phase.
I thought this adaptation conformed to your code, but I get the error that the field sfrGrowthPhases can’t be found.
Code: Select all
Forms!frmEditor.Form!Page96.SetFocus
With Forms!frmEditor!sfrGrowthPhases
.SetFocus
RunCommand acCmdRecordsGoToNew
!Week = 8.2
RunCommand acCmdSaveRecord
End With