View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
stabilo stabilo is offline
external usenet poster
 
Posts: 14
Default create a mdb databse and a table and add records from Excel VBA

I need to createa new database called db.mdb that will contains a table call
tb with a few fields (field1, field2, field3).
Then, I need to be able to add records in this table. Later in my program, I
need to run an SQL query that will returns all records if field1 is = to "X"
(then I need to list the resulting data)
I have many topics about my questions but never managed to make it work.

I have used the following example to create the database :

strDB = "D:\db.mbd" ' Create new instance of Microsoft Access.
Set appaccess = CreateObject("Access.Application")
appaccess.NewCurrentDatabase strDB
Set dbprinter = appaccess.CurrentDb
Set tbprinter = dbprinter.CreateTableDef("tb")

With tbprinter
.Fields.Append .CreateField("filed1", DB_Text)
.Fields.Append .CreateField("filed2", DB_Text)
.Fields.Append .CreateField("filed3", DB_Text)
End With
db.TableDefs.Append tb
db.Close

The database and the table is created fine, but how do I creates records and
then run my queries (the information to fill the querry is coming from a list
from LDAP) ? is there another better method to create the database and the
table (I'm under Excel2003, XP)