borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (3051 error - but why? please help)Next Topic (Pendulum motion - SIMULATION HELP Needed) New Topic New Poll Post Reply
AndreaVB Forum : Database : plz,Help required in understanding dao
Poster Message
aak_neo
Level: Scholar


Registered: 11-02-2007
Posts: 30

icon plz,Help required in understanding dao

The project aims at creating a db(db of day having 24 hour tables) at run time using module createdb. if at form load db exists then it creates another table with a different time name using another module createtb.

Sub CreateDb(Path As String)
Dim db As Database
Dim table As TableDef
Dim ID As Field
Dim DATES As Field
Dim TIM As Field
Dim CH1 As Field
Dim CH2 As Field
Dim CH3 As Field
Dim CH4 As Field
Dim CH5 As Field
Dim CH6 As Field
Dim CH7 As Field
Dim CH8 As Field
Dim REFERENCE As Field
  'Create Database
  Set db = CreateDatabase(Path, dbLangGeneral, dbEncrypt)
   'Create Table
   Set table = db.CreateTableDef(Mid$(Time$, 1, 2))
    'Create Fields.
    'For see all datatypes press F2. Library "DAO" and Classes "DataTypeEnum"
  
     Set ID = table.CreateField("ID", dbLong, 0)
      Set DATES = table.CreateField("DATES", dbText, 0)
       Set TIM = table.CreateField("TIM", dbText, 0)
      Set CH1 = table.CreateField("CH1", dbSingle, 0)
     Set CH2 = table.CreateField("CH2", dbSingle, 0)
        Set CH3 = table.CreateField("CH3", dbSingle, 0)
        Set CH4 = table.CreateField("CH4", dbSingle, 0)
        Set CH5 = table.CreateField("CH5", dbSingle, 0)
        Set CH6 = table.CreateField("CH6", dbSingle, 0)
        Set CH7 = table.CreateField("CH7", dbSingle, 0)
        Set CH8 = table.CreateField("CH8", dbSingle, 0)
        Set REFERENCE = table.CreateField("REFERENCE", dbSingle, 0)
      
       'Add Fields to Table
    'table.Fields.Append soru
    table.Fields.Append ID
    table.Fields.Append DATES
    table.Fields.Append TIM
    table.Fields.Append CH1
    table.Fields.Append CH2
    table.Fields.Append CH3
    table.Fields.Append CH4
    table.Fields.Append CH5
    table.Fields.Append CH6
    table.Fields.Append CH7
    table.Fields.Append CH8
    table.Fields.Append REFERENCE
    'Add Table to Database
    db.TableDefs.Append table
    
    'MsgBox "Your Database which name is " & table.Name & " And which version is " & db.Version & vbCrLf & _
           "created at " & table.DateCreated & " has " & table.Fields.Count & " Fields", vbInformation, "Create Database"
                
End Sub

Sub createtb()
.
.
Set db = OpenDatabase(Date$ & ".mdb") 'NOTE NO CONNECTION STRING
.
.
.
End Sub

when db does not exist it createdb executes and so suppose i call createtb by a click at some different hour(in the same run) then createtb knows which db to open,
BUT HOW DOES CREATETB MODULE KNOW IF FORM LOADS AND DB EXISTS THAT IT HAS TO OPEN THE SAME DB AS I PASS NO CONNECTION STRING & createdb was not executed in this run?  


____________________________
You never see past the choices you don't understand

13-03-2007 at 02:03 PM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : Database : plz,Help required in understanding dao
Previous Topic (3051 error - but why? please help)Next Topic (Pendulum motion - SIMULATION HELP Needed) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder