Add Record command button error message

T

Tracy

Hi,

I added a command button to my main form that would allow the user to add a
new record. However, when I click on it I get an error message saying, 'You
can't go to specified record.' Here is my code:

Private Sub AddRec_Click()
On Error GoTo Err_AddRec_Click


DoCmd.GoToRecord , , acNewRec

Exit_AddRec_Click:
Exit Sub

Err_AddRec_Click:
MsgBox Err.Description
Resume Exit_AddRec_Click

End Sub

Any suggestions on how I can get this to function correctly? Thanks.
 
B

Bob Quintal

Hi,

I added a command button to my main form that would allow the user
to add a new record. However, when I click on it I get an error
message saying, 'You can't go to specified record.' Here is my
code:

Private Sub AddRec_Click()
On Error GoTo Err_AddRec_Click


DoCmd.GoToRecord , , acNewRec

Exit_AddRec_Click:
Exit Sub

Err_AddRec_Click:
MsgBox Err.Description
Resume Exit_AddRec_Click

End Sub

Any suggestions on how I can get this to function correctly?
Thanks.
There are two possible causes to your problem.

1 the form's allowAdditions property is false.
2 the form is based on a query that does not allow new records.
 
T

Tracy

Hi Bob,

The allowAdditions property is true yet I noticed the data entry property is
false, shouldn't that be set to true, and could that be causing the problem?
Thanks.
 
D

Douglas J. Steele

No. The Data Entry property doesn't determine whether records can be added;
it only determines whether existing records are displayed.
 
L

Linq Adams via AccessMonster.com

No. Setting the Data Entry Property to Yes will allow you to ***ONLY*** add
new records; you can't view/edit existing records. AllowAdditions is set to
Yes, but the underlying Query may not allow updating. Open the query directly
and see if you can add/edit records that way.

If not, here's Allen's explanation on why you can't:

http://allenbrowne.com/ser-61.html
 

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