468,770 Members | 2,392 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,770 developers. It's quick & easy.

Access - create table DAO - but table not found

2
In access .mdb I want to create a new table with 5 fields.
Code is like:
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim fld As DAO.Field

Set db = CurrentDb()
Set tdf = db.CreateTableDef("t_comps2")
With tdf
Debug.Print "Count of fields is: " & tdf.Fields.Count
' create the fields =========
Set fld = .CreateField("compsID", dbLong)
fld.Attributes = dbAutoIncrField + dbFixedField
.Fields.Append fld
Debug.Print "Count of fields is: " & tdf.Fields.Count
'Integer field
.Fields.Append .CreateField("Appr_Num", dbSingle)
.Fields.Append .CreateField("Appr_Item", dbSingle)
'Yes/No field.
.Fields.Append .CreateField("C-s-prnt", dbBoolean)
'Memo field.
.Fields.Append .CreateField("Comps_srcs", dbMemo)
.Fields.Refresh

Debug.Print "Count of fields is: " & tdf.Fields.Count
End With
' Append TableDef object to TableDefs collection of database.
db.TableDefs.Append tdf
MsgBox "Fields have been appended to table.", vbOKOnly
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The message says fields created but I cannot find new table in database window.
Using Access 2000. ... SR-1

Where did my table go?

Thanks in advance.
Jun 17 '10 #1

✓ answered by vb5prgrmr

Are you sure you are looking at the tables window and not queries, forms, or modules? Because I don't see the new table in the module window where I had to go to paste your code... :)



Good Luck

2 1553
vb5prgrmr
305 Expert 100+
Are you sure you are looking at the tables window and not queries, forms, or modules? Because I don't see the new table in the module window where I had to go to paste your code... :)



Good Luck
Jun 18 '10 #2
mver22
2
Code does work as I submitted it. vb5prgrmr is correct about where to look (main access DATABASE window, tables section).

Problem is that new table did not show there until I reopened Access the next time. Neatly confusing!

Thank you. Case closed.
Jun 18 '10 #3

Post your reply

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

Similar topics

3 posts views Thread by mh | last post: by
1 post views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.