Results 1 to 3 of 3

Thread: Creating Access (.mdb) file from scratch! Help!!

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2000
    Posts
    135
    How do i, using ADO create an Access database (which doesnt exist) to hold my tables etc? Please help!

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    I know how to do it in DAO and then you could connect and use it with ADO. Will that work?
    Here is a little sample you can post again or use the help to look up the functions for further explanation.
    Code:
            Dim newdb As Database
            Set newdb = CreateDatabase(PassStr, dbLangGeneral)
            'make agencies table
            Dim tbAgn As TableDef
            Dim IndAgn As Index
            Set tbAgn = newdb.CreateTableDef("Agencies")
            tbAgn.Indexes.Refresh
            tbAgn.Fields.Append tbAgn.CreateField("db_ID", dbLong, 4)
            tbAgn.Fields(0).Attributes = dbAutoIncrField
            tbAgn.Fields.Append tbAgn.CreateField("Agency", dbText, 50)
            tbAgn.Fields.Append tbAgn.CreateField("Path", dbMemo)
            tbAgn.Fields.Append tbAgn.CreateField("Access", dbInteger, 2)
            tbAgn.Fields.Append tbAgn.CreateField("Notes", dbMemo)
            Set IndAgn = tbAgn.CreateIndex("db_ID")
            IndAgn.Name = "db_Index"
            IndAgn.Primary = True
            IndAgn.Fields.Append IndAgn.CreateField("db_ID", dbLong, 4)
            tbAgn.Indexes.Append IndAgn
            newdb.TableDefs.Append tbAgn
            'make settings table
            Dim tbSet As TableDef
            Dim IndSet As Index
            Set tbSet = newdb.CreateTableDef("Settings")
            tbSet.Indexes.Refresh
            tbSet.Fields.Append tbSet.CreateField("ID", dbLong, 4)
            tbSet.Fields(0).Attributes = dbAutoIncrField
            tbSet.Fields.Append tbSet.CreateField("HelpMode", dbBoolean)
            tbSet.Fields.Append tbSet.CreateField("FileOverride", dbBoolean)
            tbSet.Fields.Append tbSet.CreateField("PrintingPrompt", dbBoolean)
            tbSet.Fields.Append tbSet.CreateField("Nurses_Read Only", dbBoolean)
            tbSet.Fields.Append tbSet.CreateField("Patient_Read Only", dbBoolean)
            tbSet.Fields.Append tbSet.CreateField("SearchCommon", dbLong, 4)
            tbSet.Fields.Append tbSet.CreateField("SingleAgency", dbBoolean)
            Set IndSet = tbSet.CreateIndex("ID")
            IndSet.Name = "ID_Index"
            IndSet.Primary = True
            IndSet.Fields.Append IndSet.CreateField("ID", dbLong, 4)
            tbSet.Indexes.Append IndSet
            newdb.TableDefs.Append tbSet
            'make UserInfo table
            Dim tbUsr As TableDef
            Dim IndUsr As Index
            Set tbUsr = newdb.CreateTableDef("UserInfo")
            tbUsr.Indexes.Refresh
            tbUsr.Fields.Append tbUsr.CreateField("ID", dbLong, 4)
            tbUsr.Fields(0).Attributes = dbAutoIncrField
            tbUsr.Fields.Append tbUsr.CreateField("UserName", dbText, 50)
            tbUsr.Fields.Append tbUsr.CreateField("UserPassword", dbText, 50)
            tbUsr.Fields.Append tbUsr.CreateField("Admin Rights", dbBoolean)
            tbUsr.Fields.Append tbUsr.CreateField("Secure Lvl", dbInteger, 2)
            Set IndUsr = tbUsr.CreateIndex("ID")
            IndUsr.Name = "Usr_Index"
            IndUsr.Primary = True
            IndUsr.Fields.Append IndUsr.CreateField("ID", dbLong, 4)
            tbUsr.Indexes.Append IndUsr
            newdb.TableDefs.Append tbUsr
            'add relation here
            
            'make User_List table
            Dim tbLst As TableDef
            Set tbLst = newdb.CreateTableDef("User_List")
            tbLst.Fields.Append tbLst.CreateField("db_ID", dbLong, 4)
            tbLst.Fields.Append tbLst.CreateField("ID", dbLong, 4)
            newdb.TableDefs.Append tbLst
            Screen.MousePointer = 0
            MsgBox "Common database created", vbInformation, "Common"
            PassStr = fs.GetParentFolderName(cDlg.FileName)
            Unload Me
            Set tbLst = Nothing
            Set tbUsr = Nothing
            Set tbSet = Nothing
            Set tbAgn = Nothing
            Set IndUsr = Nothing
            Set IndSet = Nothing
            Set IndAgn = Nothing
            Set newdb = Nothing
    Its kind long but it show how to make a simple db and table.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Feb 2000
    Posts
    135

    create database

    i know how to do it using DAO but i need to know how to do it using ADO..

    Help! Please...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width