Can anyone help me with a code. I am using VB6 and need a code to automatically or dynamically load a new Access DB after a user creates it from a menu prompt I've coded:
Private Sub Command3_Click()
Dim newdata
' Dim lokatie$
Dim tb As TableDef
Dim fld As Field
Dim indx As Index
Dim DBNaam$
Dim dbNew As Database
'get name of the new database
newdata = InputBox("What's the name of the database?"
If newdata = "" Then Unload Form1
Screen.MousePointer = vbHourglass
'make database
DBNaam$ = newdata & ".mdb"
Set dbNew = CreateDatabase(DBNaam$, dbLangGeneral, dbVersion30)
'make a table
Set tb = dbNew.CreateTableDef("Table1"
'make a date-field
Set fld = tb.CreateField("Service Date", dbDate)
tb.Fields.Append fld
'make a meno-field
Set fld = tb.CreateField("Cost", dbCurrency)
tb.Fields.Append fld
'make a Yes/No field
Set fld = tb.CreateField("Odometer", dbBoolean)
tb.Fields.Append fld
'make a text field with a length of 8 characters
Set fld = tb.CreateField("Fuel Qty", dbBoolean)
tb.Fields.Append fld
Set fld = tb.CreateField("Service Type", dbText)
tb.Fields.Append fld
dbNew.TableDefs.Append tb
Screen.MousePointer = vbNormal
End Sub
At this point I have a database automatically loaded using ADO with a connection string : I need to have the program automatically load the newly created database and automatically modify the connection string.
Thanks.
Private Sub Command3_Click()
Dim newdata
' Dim lokatie$
Dim tb As TableDef
Dim fld As Field
Dim indx As Index
Dim DBNaam$
Dim dbNew As Database
'get name of the new database
newdata = InputBox("What's the name of the database?"
If newdata = "" Then Unload Form1
Screen.MousePointer = vbHourglass
'make database
DBNaam$ = newdata & ".mdb"
Set dbNew = CreateDatabase(DBNaam$, dbLangGeneral, dbVersion30)
'make a table
Set tb = dbNew.CreateTableDef("Table1"
'make a date-field
Set fld = tb.CreateField("Service Date", dbDate)
tb.Fields.Append fld
'make a meno-field
Set fld = tb.CreateField("Cost", dbCurrency)
tb.Fields.Append fld
'make a Yes/No field
Set fld = tb.CreateField("Odometer", dbBoolean)
tb.Fields.Append fld
'make a text field with a length of 8 characters
Set fld = tb.CreateField("Fuel Qty", dbBoolean)
tb.Fields.Append fld
Set fld = tb.CreateField("Service Type", dbText)
tb.Fields.Append fld
dbNew.TableDefs.Append tb
Screen.MousePointer = vbNormal
End Sub
At this point I have a database automatically loaded using ADO with a connection string : I need to have the program automatically load the newly created database and automatically modify the connection string.
Thanks.