General Development

Visual Basic 4.0 Help needed – christo


Posts: 75
Registered: 07-12-2004
This is code for a database creation program and I need help finding what is causing an error. Please Help.And if it helps I entered all this into one form.
Private Sub Form_Load()
Dim NewDb As Database, NewWs As Workspace
Set NewWs = DBEngine.Workspaces(0)
Dim Db0pts As Long
Db0pts = dbVersion30 + dbEncrypt
Set NewDb = NewWs.CreateDatabase("A:\TRITON.MDB", dbLangGeneral, Db0pts)
Dim NewTbl As TableDef
Set NewTbl = NewDb.CreateTableDef("Retail Items")
NewTbl.ValidationRule = "Retail > Wholesale"
NewTbl.ValidationText = "Retail price must exceed wholesale price."
Dim F1 As Field
Dim F2 As Field
Dim F3 As Field
Dim F4 As Field
Dim F5 As Field
Dim F6 As Field
Dim F7 As Field
Set F1 = NewTbl.CreateField("Item_Code", dbText, 10)
Set F2 = NewTbl.CreateField("Item Descrption", dbText, 50)
Set F3 = NewTbl.CreateField()
F3.Name = "Product Category"
F3.Type = dbText
F3.Size = 10
Set F4 = NewTbl.CreateField("Wholesale", dbSingle)
F4.ValidationRule = "Wholesale > 0"
F4.ValidationText = "Wholesale price must be greater than 0."
Set F5 = NewTbl.CreateField("Retail")
F5.Type = dbSingle
Set F6 = NewTbl.CreateField("Min Quantity", dbInteger)
Set F7 = NewTbl.CreateField()
F7.Name = "On Hand"
F7.Type = dbInteger
NewTbl.Fields.Append F1
NewTbl.Fields.Append F2
NewTbl.Fields.Append F3
NewTbl.Fields.Append F4
NewTbl.Fields.Append F5
NewTbl.Fields.Append F6
NewTbl.Fields.Append F7
Dim Idx1 As Index, Idx2 As Index, Fld1 As Field, Fdl2 As Field
Set Idx1 = NewTbl.CreateIndex("Item_Code")
Idx1.Primary = True
Set Fld1 = Idx1.CreateField("Item_Code")
Idx1.Fields.Append Fld1
Set Idx2 = NewTbl.CreateIndex("Price_Paid")
Idx2.Unique = False
Set Fld2 = Idx2.CreateField("Wholesale")
Fld2.Attributes = dbDecending
Idx2.Fields.Append Fld2
NewTbl.Indexes.Append Idx1
NewTbl.Indexes.Append Idx2
NewDb.TableDefs.Append NewTbl
Dim NewRel As Relation
Dim Fld3 As Field
Set NewRel = NewDb.CreateRelation("Costomer_Orders")
NewRel.Table = "Costomers"
NewRel.ForeignTable = "Orders"
Set Fld3 = NewRel.CreateField("Custno")
Fld3.ForeignName = "Custno"
NewRel.Fields.Append Fld3
NewDb.Relations.Append NewRel
End Sub



Posts: 23
From: Spencer, Iowa, USA
Registered: 07-28-2004
Hmmm, I worked with VB for a simester last school year, but you are way ahead of me lol
Sorry that I can't help...


Posts: 638
From: Vermont, USA
Registered: 03-12-2003
Well, for one, you spelled customers wrong. :-p

it might help to tell us what the actual error is.

"I find myself a desire which no experience in this world can satisfy, the most probable explanation is that I was made for another world!"
-C. S. Lewis


[This message has been edited by InsanePoet (edited July 30, 2004).]



Posts: 3450
From: SV, CA, USA
Registered: 01-29-2002
I used to knew VB 4, but... forgot it. and, you are still beyond what I knew. sry.

Soterion Studios