Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 820303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T02:27:13+00:00 2026-05-15T02:27:13+00:00

So I have the below VB that creates an access file in the default

  • 0

So I have the below VB that creates an access file in the default workspace, creates a table, create some fields in that table…just need to know the syntax for setting the first data type/field to autonumber…GUID, Counter, etc will not work as in Access SQL

' error handling usually goes here

dim ws as workspace
dim dbExample as database
dim tblMain as TableDef
dim fldMain as Field
dim idxMain as Index

set ws = workspace(0)

set dbExample = ws.CreateDatabase('string file path')

set tblMain = dbExample.CreateTableDef("tblMain")

set fldMain = tblMain.CreateField("ID", 'right here I do not know what to substitute for dbInteger to get the autonumber type to work )

tblMain.Fields.Append fldMain
etc to create other fields and indexes

so in this line:
set fldMain = tblMain.CreateField(“ID”, dbInteger)
i need to replace the dbInteger with something that VB reconizes as the autonumber property.
i have tried GUID, Counter, Autonumber, AutoIncrement….unfortunately none of these work

anyone know the syntax I am missing here?

Thanks,
Justin

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T02:27:13+00:00Added an answer on May 15, 2026 at 2:27 am

    See Creating an AutoNumber field from code at The access Web.

    Here are the key lines from that linked page:

    Set db = Application.CurrentDb
    Set tdf = db.TableDefs(strTableName)
    ' First create a field with datatype = Long Integer '
    Set fld = tdf.CreateField(strFieldName, dbLong)
    With fld
        ' Appending dbAutoIncrField to Attributes '
        ' tells Jet that its an Autonumber field '
        .Attributes = .Attributes Or dbAutoIncrField
    End With
    With tdf.Fields
        .Append fld
        .Refresh
    End With
    

    BTW, what you’re doing is not DDL.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following table: I am trying to create an SQL query that
I have some confusion with singleton class, below are my some points: Can singleton
I have included my source code draft below. I would appreciate any input on
I have a model like the one below. When an instance is created, I
i want to use my ldap server as a DB. then i will create
It seems that this question gets asked frequently , but I am not coming
I have finally created a very simple Hello World style PHP Extension dll on
I adapted this tutorial (http://www.screaming-penguin.com/node/7749) to an Android app I've built to allow for
Relatively new with SVN. I am using svn on local system (OpenSuSE 11.3). I
I am hitting a brick wall with something I'm trying to do. I'm trying

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.