Click to See Complete Forum and Search --> : Can anyone give me a sample


kirkdm22
November 25th, 1999, 04:29 AM
Can anyone give me a sample or tell me how to make tables in VB6 to store data like Access does from a newbie
reply:
or send email: kirkdm22@hotmail.com

regis
November 25th, 1999, 07:43 AM
*Sorry for my explication in french.


Dim dbsNew As Database
Dim wrkDefault As Workspace

'// Obtient l'objet Workspace par défaut.
'// Take the object Workspace by default
Set wrkDefault = DBEngine.Workspaces(0)

'// Vérifie qu'aucun fichier ne porte le nom de 'la nouvelle base de données.
'//Look if anyone file have the same name
If Dir("MarteleurVirtuel.mdb") <> "" Then Kill _ "MarteleurVirtuel.mdb"

'//Crée une nouvelle base de données cryptée avec 'l'ordre de classement précisé.
'//Make a new Data Base
Set dbsNew = wrkDefault.CreateDatabase("c: _\Windows\Temp\MarteleurVirtuel.mdb", _
dbLangGeneral, dbEncrypt)

'// Création de la table Position ha //////
'// Create table in Data Base //////
Dim td As TableDef
Dim f As Field
Dim ind As Index

Set td = New TableDef

Set f = New Field
f.Name = "Position_ha_x"
f.Type = dbInteger
f.Size = 20
td.Fields.Append f

Set f = New Field
f.Name = "Position_ha_y"
f.Type = dbInteger
f.Size = 20
td.Fields.Append f

Set f = New Field
f.Name = "No_ha"
f.Type = dbInteger
f.Size = 30
td.Fields.Append f

'index
Set ind = New Index
ind.Name = "No_ha_ind"
ind.Fields = "No_ha"
ind.Primary = True
ind.Unique = True
td.Indexes.Append ind

'// Put Table in Data Base
td.Name = "Position ha"
dbsNew.TableDefs.Append td


I hope so this code it's will be good for you!

* If you have numeric field, you can put dbBouble in f.Type I think is will be better and if you have the texte field put dbText.

Bye!