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"
myConnection.Open
End Sub
this is the code snippet that am using
am getting syntax error in crate table satement
plz help me out

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........

Hi,

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)")


REgards
Veena

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.....

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

This article has been dead for over six months. Start a new discussion instead.