VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Create Access Table in VB


Category: Databases/Data Access/DAO/ADO
Compatability: Visual Basic 3.0
Difficulty: Advanced
Date Added: Wed 3rd February 2021
Rating: (6 Votes)

Allows the programmer to create an MS Access table in Visual Basic where the primary key’s field data type is set to AutoNumber. It is not like creating the primary key field in Access where you can select AutoNumber date type. In VB 5 and 6 you can’t request AutoNumber for a field type in the SQL Create Table string, it does not exist. So to create a table in VB where primary key’s numeric field type will be AutoNumber, you have to do it the way the included source code shows. Hope this helps.

Inputs
None.
Assumes
None.
Code Returns
None.
Side Effects
None.
API Declarations
None.

Rate Create Access Table in VB

Private Sub Creat_Table()
 Dim stSQLstr As String
 Dim dbs As Database
 stSQLstr = "CREATE TABLE NameTbl (NameID COUNTER CONSTRAINT PrimaryKey PRIMARY KEY, FirstName Text (15), LastName Text (20));"
  Set dbs = OpenDatabase("c:\test\Demo.mdb")
  dbs.Execute stSQLstr
  dbs.Close
End Sub

Download this snippet    Add to My Saved Code

Create Access Table in VB Comments

No comments have been posted about Create Access Table in VB. Why not be the first to post a comment about Create Access Table in VB.

Post your comment

Subject:
Message:
0/1000 characters