My goal is to automate a process via Macros, without that the user of the database has to touch the design view etc.
I have one table met 1 field = Road_id, but know, I'd like to add a second field (ex. auto_id) and have this one in autonumber, for example:
road_id & auto_id
5 & 1
8 & 2
99 & 3
852 & 4
The problem is, I want to add this second automatically (without having to go in designview and add a field "auto_id" with datatype AutoNumber).
I tried via an sql-specific-query but the datatype 'AutoNumber' is not recognised. Then I tried via Code, but again, no datatype 'Autonumber' is possible:
------------
Sub CreateTable()
Dim dbs As Database
Dim tbl As TableDef
Set dbs = CurrentDb
Set tbl = dbs.TableDef("New_ManoeuvreR")
With tbl
.Fields.Append .CreateField("auto_id", ????)
dbs.TableDefs.Append tbl
End With
End Sub
-----------
Can someone help me to resolve this? Thanks a lot in advance!
I have one table met 1 field = Road_id, but know, I'd like to add a second field (ex. auto_id) and have this one in autonumber, for example:
road_id & auto_id
5 & 1
8 & 2
99 & 3
852 & 4
The problem is, I want to add this second automatically (without having to go in designview and add a field "auto_id" with datatype AutoNumber).
I tried via an sql-specific-query but the datatype 'AutoNumber' is not recognised. Then I tried via Code, but again, no datatype 'Autonumber' is possible:
------------
Sub CreateTable()
Dim dbs As Database
Dim tbl As TableDef
Set dbs = CurrentDb
Set tbl = dbs.TableDef("New_ManoeuvreR")
With tbl
.Fields.Append .CreateField("auto_id", ????)
dbs.TableDefs.Append tbl
End With
End Sub
-----------
Can someone help me to resolve this? Thanks a lot in advance!