I have a form with a tab control.
In the tab control, I have inserted a subform.
I have a command button in the subform to add a new record.
I can't seem to make it work.
For debugging purposes, I have replicated these conditions in a simple database and the command button works. This is the code I am using.
Private Sub Command6_Click()
Forms!frmTable1!frmTable2.SetFocus 'See note 1
Forms!frmTable1!frmTable2.Form!PK2.SetFocus 'focus on primary key
DoCmd.RunCommand acCmdRecordsGoToNew
End Sub
'Note 1: I can omit this line and the command button still works
I changed my code in the actual database to be equivalent and it looks like this...
Forms!frmPlay_Input!Formations.SetFocus
Forms!frmPlay_Input!SubFormations.Form!FID.SetFocus
DoCmd.RunCommand acCmdRecordsGoToNew
and it does not work...the error trapping gives ERROR 2046...THE COMMAND OR ACTION 'RecordsGoToNew' isn't available now.
I used conditional formatting to confirm that the textbox with the primary key on the subform actually has focus.
Any advice how I can continue debugging this...
In the tab control, I have inserted a subform.
I have a command button in the subform to add a new record.
I can't seem to make it work.
For debugging purposes, I have replicated these conditions in a simple database and the command button works. This is the code I am using.
Private Sub Command6_Click()
Forms!frmTable1!frmTable2.SetFocus 'See note 1
Forms!frmTable1!frmTable2.Form!PK2.SetFocus 'focus on primary key
DoCmd.RunCommand acCmdRecordsGoToNew
End Sub
'Note 1: I can omit this line and the command button still works
I changed my code in the actual database to be equivalent and it looks like this...
Forms!frmPlay_Input!Formations.SetFocus
Forms!frmPlay_Input!SubFormations.Form!FID.SetFocus
DoCmd.RunCommand acCmdRecordsGoToNew
and it does not work...the error trapping gives ERROR 2046...THE COMMAND OR ACTION 'RecordsGoToNew' isn't available now.
I used conditional formatting to confirm that the textbox with the primary key on the subform actually has focus.
Any advice how I can continue debugging this...