error 3265 vb6 (1 Viewer)

boyoman

New member
Local time
Today, 20:22
Joined
Sep 3, 2021
Messages
2
Set DbWorkSpace = DBEngine.Workspaces(0)
Set DBaseNew = DbWorkSpace.OpenDatabase(DBasePC, True)
Set DbField = DBaseNew.CreateTableDef(NFileName)
With DbField
.Fields.Append .CreateField("pSlip", dbText, 200) "how to add new this fields in existing database
End With
DBaseNew.Close
Untitled03.png
 

Ranman256

Well-known member
Local time
Today, 08:22
Joined
Apr 9, 2015
Messages
4,337
FIELDS is not a property of DBFIELD, it is of a table.
when you press the period beside the object, you will see all its properties.
 

boyoman

New member
Local time
Today, 20:22
Joined
Sep 3, 2021
Messages
2
If Not Fsys.FileExists(DBasePC) Then
Set DBaseNew = DbWorkSpace.CreateDatabase(DBasePC, dbLangGeneral, dbEncrypt)
Set DBaseNew = DbWorkSpace.OpenDatabase(DBasePC, True, False)
Set DbField = DBaseNew.CreateTableDef(NFileName)
With DbField
.Fields.Append .CreateField("pCategory", dbText, 200) ' exist field
End With
DBaseNew.TableDefs.Append DbField
DBaseNew.Close
Else
Set DbWorkSpace = DBEngine.Workspaces(0)
Set DBaseNew = DbWorkSpace.OpenDatabase(DBasePC, True)
Set DbField = DBaseNew.CreateTableDef(NFileName)
With DbField
.Fields.Append .CreateField("pSlip", dbText, 200) 'add a new field
End With
DBaseNew.Close
End If
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 07:22
Joined
Feb 28, 2001
Messages
27,194
Your nomenclature is your choice, but I will say that it is confusing to re-use objects like that. Still, not illegal.

Your "With DbField" probably should instead be something like "With TableDefs(NFileName)" since that is the tabledef you just created. (I say "should be" not for syntax or semantics, but for clarity.)

I had to look it up because that function is one I rarely use. I prefer statically defined tables. However, the .CreateTableDef does, indeed, return a TableDef. It should be possible to do what you want. Here is an older reference that I think is still valid:

 

Users who are viewing this thread

Top Bottom