Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

invalid create table statement

Status
Not open for further replies.

NITIN27

Programmer
Dec 11, 2003
24
IN
HI
what are datatypes we can use in microsoft access
for character,date,time,numeric and pls. do tell their
syntax
eg
create table aa(
name char(30),
e_date date,
amt number(10,2));

showing a error invalid create table statement

thanks in advance
 
Hi,

to programatically create a table in Access you would need to use something like the following;

Code:
Dim db As DAO.Database
Dim tdfTable As New DAO.TableDef
Dim fld1 As New DAO.Field
Dim fld2 As New DAO.Field
Dim fld3 As New DAO.Field

Set db = CurrentDb
tdfTable.Name = "aa"

With fld1
    .Type = dbText
    .Name = "Name"
End With

With fld2
    .Type = dbDate
    .Name = "e_date"
End With

With fld3
    .Type = dbLong
    .Name = "amt"
End With

With tdfTable.Fields
    .Append fld1
    .Append fld2
    .Append fld3
End With

With db.TableDefs
    .Append tdfTable
    .Refresh
End With

Application.RefreshDatabaseWindow

To the best of my knowledge Access doesnt support the 'CREATE' command and its Make Table query isnt applicable to what you need to do.

Hope that points you in the right direction.

Simon


----------------------------------------
Of all the things I have lost in my life, the thing I miss the MOST is my mind!
----------------------------------------
 
CurrentDb.Execute "create table myTbl(Fld1 text(50),Fld2 datetime , Fld3 number)"

This will give you your three field (you can change Fld1, Fld2 and Fld3 to other names). I'm not sure how you format those datetime and number fields. If I figure that out, I will post that info.

Paul
 
When creating a number field, you can use

Fld3 Double

or Single or Integer to specify what you want for Field Size. Still working on the DateTime.

Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top