
Problem with "Dim as Field"
Quote:
>Hi,
>I use VB4/16 under Win95.
>I try to add a field to a TabeleDef.
>But I get an error 91 (Object-variable not defined)
>I have no problem opening databases and creating recordsets, why can I not
>define a new field ?
>What is wrong with my code ?
>Dim myField as Field
>myField.Name = "Name" <--- error 91
>myField.Type = dbtext
>....
>T I A
>heinz
Heinz,
Try changing your code to:
Dim myField as New Field
myField.Name = "Name"
myField.Type = dbtext
---------------------------------
The problem is that you declared a variable of type Field but that just sets
up storage for a pointer to a Field object. Using the New keyword creates an
instance of the Field object and sets myField to point to it.
Alternatively, you could separate the Dim and the assign by using the
following code:
Dim myField as Field
Set myField = New Field
.
.
.
----------------------------------
Hope this helps.
-Stu