Problem adding new records

G

Guest

I've recently upgradded to Access 2007. I've created a form that is attached
to a single table with no relationships. I have an Account Number field
(text, indexed, no duplicates) that I've written code to increment. I call
this code when the "NEW" button is clicked (onClick event) as follows:

Me.DataEntry = True
DoCmd.GoToRecord ,, acNewRec
Me.acct_no = <VBA CODE>

But I get the proverbial "can't go to record" error!!! I've been at it all
day and I think I need another pair of eyes. By the way, this table DOES NOT
have a primary key.

Thanks for any help...
 
G

Guest

First of all, Account Number should be your primary key and you should avoid
spaces in your field names.

You don't need the line:
Me.DataEntry = True

Since you are using DoCmd to go to a new record. Use one or the other...

Steve
 
G

Guest

Steve,

Thanks for your reply. As an FYI, the field name is acct_no, not Account
Number.

The original table design used acct_no as the primary key AND I had a "New
Record" button built with the button wizard but I was still getting the same
error. I removed the primary key (even though the acct_no is indexed, no
duplicates) in an attempt to eliminate the problem, but no joy. I'm
wondering if this is a bug with 2007 - I've never had this problem with
earlier versions of Access.

Your thoughts?
 
G

Guest

Okay - I found the problem....

In Access 2007, the form property :Recordset Type is "Dynaset" by default.
If you want to add records with a form, this property must be set to "Dynaset
(Inconsistent Updates)".
 

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