Leif
2007-05-14 17:15:01 UTC
I'm trying to create a new record from a form. To do this I have a button
labeled "Create". The VBA coding for the Create button is below. I get an
error on the line " DoCmd.RunCommand acCmdRecordsGoToNew". The error I
get is "The command or action 'RecordsGoToNew' isn't available now." If I
comment out that line it runs, but as soon as I type a letter in the form a
pop comes up saying "You can't assign a value to this object". Once I click
OK, however, I can go ahead and add the record. I "think" the form is not
yet on a new record. That is what the acCmdRecordsGoToNew is suppose to do.
However, I get the isn't available now message. Thanks for your help.
Private Sub cmd_New_Click()
On Error GoTo Err_cmd_New_Click
Me.Dpmt = Null
Me.WrkGrp = Null
Me.Team = Null
Me.Role = Null
Me.sfrm_Profile_Annotator_EditA.Requery
'Unlock the Role Profile Annotator subforms, allow additions, and move focus
to the subform and move to a new record
Me.sfrm_Profile_Annotator_EditA.Locked = False
Me.sfrm_Profile_Annotator_EditB.Locked = False
Me.sfrm_Profile_Annotator_EditC.Locked = False
Me.sfrm_Profile_Annotator_EditD.Locked = False
'Allow additions
Me.sfrm_Profile_Annotator_EditA.Form.AllowAdditions = True
Me.sfrm_Profile_Annotator_EditB.Form.AllowAdditions = True
Me.sfrm_Profile_Annotator_EditC.Form.AllowAdditions = True
Me.sfrm_Profile_Annotator_EditD.Form.AllowAdditions = True
'Allow Shortcut Menus
Me.sfrm_Profile_Annotator_EditA.Form.ShortcutMenu = True
Me.sfrm_Profile_Annotator_EditB.Form.ShortcutMenu = True
Me.sfrm_Profile_Annotator_EditC.Form.ShortcutMenu = True
Me.sfrm_Profile_Annotator_EditD.Form.ShortcutMenu = True
DoCmd.GoToControl "sfrm_Profile_Annotator_EditA"
DoCmd.RunCommand acCmdRecordsGoToNew
DoCmd.GoToControl "Assigned"
' Update locked status on subform
Me.sfrm_Profile_Annotator_EditA.Form.SPA_AfterUpdate
Me.sfrm_Profile_Annotator_EditA.Form.TAPresent_AfterUpdate
Err_cmd_New_Click_Exit:
Exit Sub
Err_cmd_New_Click:
Resume Next
Resume Err_cmd_New_Click_Exit
End Sub
labeled "Create". The VBA coding for the Create button is below. I get an
error on the line " DoCmd.RunCommand acCmdRecordsGoToNew". The error I
get is "The command or action 'RecordsGoToNew' isn't available now." If I
comment out that line it runs, but as soon as I type a letter in the form a
pop comes up saying "You can't assign a value to this object". Once I click
OK, however, I can go ahead and add the record. I "think" the form is not
yet on a new record. That is what the acCmdRecordsGoToNew is suppose to do.
However, I get the isn't available now message. Thanks for your help.
Private Sub cmd_New_Click()
On Error GoTo Err_cmd_New_Click
Me.Dpmt = Null
Me.WrkGrp = Null
Me.Team = Null
Me.Role = Null
Me.sfrm_Profile_Annotator_EditA.Requery
'Unlock the Role Profile Annotator subforms, allow additions, and move focus
to the subform and move to a new record
Me.sfrm_Profile_Annotator_EditA.Locked = False
Me.sfrm_Profile_Annotator_EditB.Locked = False
Me.sfrm_Profile_Annotator_EditC.Locked = False
Me.sfrm_Profile_Annotator_EditD.Locked = False
'Allow additions
Me.sfrm_Profile_Annotator_EditA.Form.AllowAdditions = True
Me.sfrm_Profile_Annotator_EditB.Form.AllowAdditions = True
Me.sfrm_Profile_Annotator_EditC.Form.AllowAdditions = True
Me.sfrm_Profile_Annotator_EditD.Form.AllowAdditions = True
'Allow Shortcut Menus
Me.sfrm_Profile_Annotator_EditA.Form.ShortcutMenu = True
Me.sfrm_Profile_Annotator_EditB.Form.ShortcutMenu = True
Me.sfrm_Profile_Annotator_EditC.Form.ShortcutMenu = True
Me.sfrm_Profile_Annotator_EditD.Form.ShortcutMenu = True
DoCmd.GoToControl "sfrm_Profile_Annotator_EditA"
DoCmd.RunCommand acCmdRecordsGoToNew
DoCmd.GoToControl "Assigned"
' Update locked status on subform
Me.sfrm_Profile_Annotator_EditA.Form.SPA_AfterUpdate
Me.sfrm_Profile_Annotator_EditA.Form.TAPresent_AfterUpdate
Err_cmd_New_Click_Exit:
Exit Sub
Err_cmd_New_Click:
Resume Next
Resume Err_cmd_New_Click_Exit
End Sub