By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,962 Members | 1,997 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,962 IT Pros & Developers. It's quick & easy.

table created dynamically

palsonjj
P: 18
haai,
how to create MS Access Table dynamically in VB? any idea..........................
Apr 20 '07 #1
Share this Question
Share on Google+
9 Replies


P: 47
haai,
how to create MS Access Table dynamically in VB? any idea..........................
Expand|Select|Wrap|Line Numbers
  1.  cnn.Execute "create table BX (CNT_NO NUMBER,RG TEXT(2),BRN TEXT(3),DOC TEXT(1),BDSRL NUMBER)"
  2.  
Apr 20 '07 #2

palsonjj
P: 18
Expand|Select|Wrap|Line Numbers
  1.  cnn.Execute "create table BX (CNT_NO NUMBER,RG TEXT(2),BRN TEXT(3),DOC TEXT(1),BDSRL NUMBER)"
  2.  

Haaai, thnks 4 ur replyin... i've 1 more doubt.. wher shud tat table stored ? can v giv any default path?
Apr 21 '07 #3

palsonjj
P: 18
Haaai, thnks 4 ur replyin... i've 1 more doubt.. wher shud tat table stored ? can v giv any default path?


Yeeeeeeeeeeeeeeeaaaaaaaaaaaaaaaaah , it's workin........ ;) ..thnku vry much .......
Apr 21 '07 #4

debasisdas
Expert 5K+
P: 8,127
The table will be created in the .MDB file (access database) specified in the connection string.
Apr 21 '07 #5

palsonjj
P: 18
The table will be created in the .MDB file (access database) specified in the connection string.

haaai, thnku .... it's workin....... thn, can v create query table using dis same method?
Apr 21 '07 #6

debasisdas
Expert 5K+
P: 8,127
if u r still using DAO then u can go for the following method


Dim W As Workspace
Dim D As Database
Dim T As TableDef
Dim F(5) As Field

Private Sub Command1_Click()
Set W = DBEngine.Workspaces(0)
Set D = W.CreateDatabase("D:\EMP.MDB", dbLangGeneral)
Set T = D.CreateTableDef("EMPLOYEE")
Set F(0) = T.CreateField("EMPNO", dbInteger)
Set F(1) = T.CreateField("ENAME", dbText, 20)
Set F(2) = T.CreateField("DEPTNO", dbInteger)
Set F(3) = T.CreateField("SALARY", dbSingle)
Set F(4) = T.CreateField("JOINDATE", dbDate)
T.Fields.Append F(0)
T.Fields.Append F(1)
T.Fields.Append F(2)
T.Fields.Append F(3)
T.Fields.Append F(4)
D.TableDefs.Append T
MsgBox ("DATABASE CREATED")
End Sub
Apr 21 '07 #7

palsonjj
P: 18
if u r still using DAO then u can go for the following method


Dim W As Workspace
Dim D As Database
Dim T As TableDef
Dim F(5) As Field

Private Sub Command1_Click()
Set W = DBEngine.Workspaces(0)
Set D = W.CreateDatabase("D:\EMP.MDB", dbLangGeneral)
Set T = D.CreateTableDef("EMPLOYEE")
Set F(0) = T.CreateField("EMPNO", dbInteger)
Set F(1) = T.CreateField("ENAME", dbText, 20)
Set F(2) = T.CreateField("DEPTNO", dbInteger)
Set F(3) = T.CreateField("SALARY", dbSingle)
Set F(4) = T.CreateField("JOINDATE", dbDate)
T.Fields.Append F(0)
T.Fields.Append F(1)
T.Fields.Append F(2)
T.Fields.Append F(3)
T.Fields.Append F(4)
D.TableDefs.Append T
MsgBox ("DATABASE CREATED")
End Sub

Haaai, Database s created . but, "Set F(0) = T.CreateField("EMPNO", dbInteger)" dis line has error --- Type mismatch... ??????
Apr 21 '07 #8

debasisdas
Expert 5K+
P: 8,127
have u referred to DAO LIBRARY in project---references
dao 3.51
or
dao 3.6
Apr 21 '07 #9

palsonjj
P: 18
have u referred to DAO LIBRARY in project---references
dao 3.51
or
dao 3.6



yes..... i've already added tat...
Apr 23 '07 #10

Post your reply

Sign in to post your reply or Sign up for a free account.