Make Table Query and Autonumber Fields

C

croy

In Access 2002, what triggers a MakeTable query to create a
field as an Autonumber field?
 
B

Bob Barrows

croy said:
In Access 2002, what triggers a MakeTable query to create a
field as an Autonumber field?

Nothing. It can't be done. You can only create an Autonumber field in Design
View, or via a CREATE/ALTER TABLE DDL statement..

That means, if you need the resulting table to have an Autonumber field, you
have to create the table ahead of time and change the Make-table query to an
Append query.
 
C

croy

Nothing. It can't be done. You can only create an Autonumber field in Design
View, or via a CREATE/ALTER TABLE DDL statement..

That means, if you need the resulting table to have an Autonumber field, you
have to create the table ahead of time and change the Make-table query to an
Append query.

Actually, what I want is for a Make-table query to *not*
generate an Autonumber field.

My Make-table query is failing with the error, "You tried to
assign the Null value to a variable that is not a Variant
data type." There is one field in the query that seems to
want to be an Autonumber field, but I can't figure out why.

According to KB 197587, the query is failing because it is
creating an Autonumber field and then trying to put a null
in it. The KB only gives a workaround--build the table
first, avoiding Autonumber fields, and then use an append
query. That's how I got interested in the subject of this
thread.
 
B

Bob Barrows

croy said:
Actually, what I want is for a Make-table query to *not*
generate an Autonumber field.

My Make-table query is failing with the error, "You tried to
assign the Null value to a variable that is not a Variant
data type." There is one field in the query that seems to
want to be an Autonumber field, but I can't figure out why.

According to KB 197587, the query is failing because it is
creating an Autonumber field and then trying to put a null
in it. The KB only gives a workaround--build the table
first, avoiding Autonumber fields, and then use an append
query. That's how I got interested in the subject of this
thread.

I guess either the behavior changed after A97 ... or my memory is failing
me, which is a distinct possiblity. I've just tried a test make-table query
using data from a table containing an autonumber field and, to my surprise,
the resulting table contained an autonumber field!

So it seems like the only way to avoid the autonumber is
1. not to include the autonumber field from the source in your select.
2. use the autonumber field in an expression so a new non-autonumber field
has to be created, like this:
select CLng(autonumberfield) as nonautonumber into newtable from oldtable
 
D

David-W-Fenton

Nothing. It can't be done. You can only create an Autonumber field
in Design View, or via a CREATE/ALTER TABLE DDL statement..

That means, if you need the resulting table to have an Autonumber
field, you have to create the table ahead of time and change the
Make-table query to an Append query.

That's just not true. When you use a MakeTable query and one of the
source fields is an Autonumber, the resulting table that is made has
an Autonumber type, as well.
 
B

Bob Barrows

David-W-Fenton said:
That's just not true. When you use a MakeTable query and one of the
source fields is an Autonumber, the resulting table that is made has
an Autonumber type, as well.

So I found out, as you will see when you read my later reply. I don't know
where I got this wrong idea. Oh well, this is my something-new-learned for
today.
 

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