i want to create table in ms acces database during run time.........
Dim myConnection As ADODB.Connection
Dim Conn As String
Dim vtblNametxt As String

Private Sub cratblebtn_Click()
vtblNametxt = tblNametxt.Text
myConnection.Execute ("create table " & vtblNametxt & " (id varchar2(3),pname varchar2(20), qtyp number(4));")
End Sub

Private Sub Form_Load()
Set myConnection = New ADODB.Connection
myConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & App.Path & "\\database.mdb"
End Sub
this is the code snippet that am using
am getting syntax error in crate table satement
plz help me out

Recommended Answers

All 8 Replies

hey veena thanx
that really helps
but actually i want to know wheter the piece of code snippet that i posted is correct or is it wrong
cant i create a table in exsisting database at runtime using create table command and ms access as backend
plz reply........


CREATE Table DDL is Enabled for Access 2K and higher..
Also note :
use Text instead of Varchar2
use Long instead on Number

some thing like this :
myConnection.Execute ("create table " & vtblNametxt & " (id Text(3), pname Text(20), qtyp Long)")


hey veena thanx........it helped :)

the syntax is creating table properly but when i give ame of teh table with a space in betwee it gives syntax error..........like if i create table with name"hello" it works fine bt when i use"hello world" it gives error..........can neone resolve this plz.....

enclose the table name in []


[hello world]

hope it solves ur problem

Shaik Akthar

hey thanks athar........it worked........:)

im having the same problem..i didnt understand using [] solved ur problem but didnt work for me...could u kindly explain..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.