Why "DataEntry is not Available now"?

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
 
V

Van T. Dinh

Is the Form's RecordSource based on a Query?

If it is, check and make sure your Query is updateable, i.e. you can edit
data and add new Records in the DatasheetView of the Query.
 
G

Guest

Van,

Thanks for the message. Yes, the form's RecordSource is based on a query. It
seems the query is not updatable... I cannot edit or add new records on
Datasheet view of the query. How should I make the query updatable?

Really appreicate your help!

Ally



Van T. Dinh said:
Is the Form's RecordSource based on a Query?

If it is, check and make sure your Query is updateable, i.e. you can edit
data and add new Records in the DatasheetView of the Query.

--
HTH
Van T. Dinh
MVP (Access)


Ally said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top