G
Guest
I have a Command button called "AddNew" on a form which allows a user to add
a new record. I used: DoCmd.RunCommand acCmdDataEntry in the AddNew_Click
Subfunction as below. However, everytime when I click "AddNew" button. A
error message pops up saying: "Run time error "2046": The command or ation
'DataEntry' isn't available now."
Here is my Click Sub:
Private Sub cmdAddNew_Click()
' If changes on this row, then save first
If Me.Dirty Then
If IsNothing(Me![SIPID]) Then
MsgBox "Must save current record with a valid SIPID# before
adding another.", vbCritical, "Microsoft Press"
Exit Sub
End If
DoCmd.RunCommand acCmdSaveRecord
End If
' Execute a Data Entry command
DoCmd.RunCommand acCmdDataEntry
Me![SIPID].SetFocus
Me!cmdAddNew.Visible = False
Me!cmdShowAll.Visible = True
Me!cmdSearch.Enabled = False
End Sub
Does anyone know why this happened? I checked the form property settings, I
have AllowEdits set to Yes; AllowDeletions set to Yes; AllowAdditions set to
Yes; DataEntry set to No. Even though I change DataEntry setting to "Yes", I
still got the same error message. Would someone please let me know why? What
did I wrong?
P.S: I used this code for AddNew button on other forms. It works
well. But I have no idea why it does not work this time.
I really appreciate your help!
Thanks in advance!
Ally
a new record. I used: DoCmd.RunCommand acCmdDataEntry in the AddNew_Click
Subfunction as below. However, everytime when I click "AddNew" button. A
error message pops up saying: "Run time error "2046": The command or ation
'DataEntry' isn't available now."
Here is my Click Sub:
Private Sub cmdAddNew_Click()
' If changes on this row, then save first
If Me.Dirty Then
If IsNothing(Me![SIPID]) Then
MsgBox "Must save current record with a valid SIPID# before
adding another.", vbCritical, "Microsoft Press"
Exit Sub
End If
DoCmd.RunCommand acCmdSaveRecord
End If
' Execute a Data Entry command
DoCmd.RunCommand acCmdDataEntry
Me![SIPID].SetFocus
Me!cmdAddNew.Visible = False
Me!cmdShowAll.Visible = True
Me!cmdSearch.Enabled = False
End Sub
Does anyone know why this happened? I checked the form property settings, I
have AllowEdits set to Yes; AllowDeletions set to Yes; AllowAdditions set to
Yes; DataEntry set to No. Even though I change DataEntry setting to "Yes", I
still got the same error message. Would someone please let me know why? What
did I wrong?
P.S: I used this code for AddNew button on other forms. It works
well. But I have no idea why it does not work this time.
I really appreciate your help!
Thanks in advance!
Ally