#DEFINE adText 10
cTbl="NewTable"
cMDB="C:\Files\NewDatabase.MDB"
oAcc=CREATEOBJECT("Access.Application")
oAcc.NewCurrentDatabase(cMDB) && Makes the new DB
oMDB=oAcc.CurrentDB
oTbl=oMDB.CreateTableDef(cTbl) && Makes the new table
oFld=oTbl.CreateField("Name")
oFld.Type = adText && Could be one of about 18 types...
oFld.Size = 30 && Size only counts for Text (mainly)
oTbl.Fields.Append(oFld) && Append field def to table def
oFld=oTbl.CreateField("Address")
oFld.Type = adText
oFld.Size = 40
oTbl.Fields.Append(oFld)
oFld=oTbl.CreateField("Phone")
oFld.Type = adText
oFld.Size = 20
oTbl.Fields.Append(oFld)
oMDB.TableDefs.Append(oTbl) && Append table def to database definitions
oRS=oMDB.OpenRecordSet(cTbl) && Create an rs managed by Access workspace
oRS.AddNew && Kinda like APPEND BLANK
oRS.Fields("Name").Value = "John Smith"
oRS.Fields("Address").Value = "100 Main Street"
oRS.Fields("Phone").Value = "(850) 555-1212"
oRS.Update
oRS.MoveFirst && Ensures that the RS is updated, kinda like opt. row. buff.
oRS.Close
oAcc.Quit(1)
RELEASE oAcc
>I am trying to create the access DB and add the data to a table within that access database within the foxpro program. Any ideas?------------------------------------------------
John Koziol, ex-MVP, ex-MS, ex-FoxTeam. Just call me "X"
"When the going gets weird, the weird turn pro" - Hunter Thompson (Gonzo) RIP 2/19/05