make mdb field "Allow Zero Length"

make mdb field "Allow Zero Length"

Post by John A Grand » Fri, 28 Sep 2001 07:22:16



when creating an mdb field within VB code, i want achieve the same effect as
when in Access setting the "Allow Zero Length" property to "True"
 
 
 

make mdb field "Allow Zero Length"

Post by Robin Sh » Fri, 28 Sep 2001 12:18:49


As you are asking ADO, I assume you are using ADOX to create the Access
database. Then we just need to set the "Jet OLEDB:Allow Zero Length"
property of the column object.

Please reference the article HOWTO: Use ADOX to Create an AutoNumber Field
of Replication ID Field Size at
http://support.microsoft.com/support/kb/articles/Q297/9/80.ASP for sample
code regarding to this.

Hope this helps,

Robin

 
 
 

make mdb field "Allow Zero Length"

Post by Bob Barro » Fri, 28 Sep 2001 22:05:36


On Wed, 26 Sep 2001 15:22:16 -0700, "John A Grandy"


>when creating an mdb field within VB code, i want achieve the same effect as
>when in Access setting the "Allow Zero Length" property to "True"

You need to use ADOX for this. This article:

<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnda...>

gives you a good overview. Make sure you look in the appendix for the
farous Jet properties that can be set via ADOX. And make sure you have
Jet 4.0 SP5 installed.

Just don't duplicate the author's use of

Dim var As New Something.

Instead, when you use her sample code, change it to
Dim var As Something
Set var = New Something

The former syntax, while it works, has fallen out of favor with
experienced programmers who wish to retain control over when objects
are created and destroyed.

HTH,
Bob Barrows
Please reply to the newsgroup. My reply-to address is my "spam trap" and I don't check it very often.

 
 
 

make mdb field "Allow Zero Length"

Post by John A Grand » Sat, 29 Sep 2001 08:16:32


sorry. i meant to say that i need to do this using sql.


Quote:> As you are asking ADO, I assume you are using ADOX to create the Access
> database. Then we just need to set the "Jet OLEDB:Allow Zero Length"
> property of the column object.

> Please reference the article HOWTO: Use ADOX to Create an AutoNumber Field
> of Replication ID Field Size at
> http://support.microsoft.com/support/kb/articles/Q297/9/80.ASP for sample
> code regarding to this.

> Hope this helps,

> Robin

 
 
 

make mdb field "Allow Zero Length"

Post by Bob Barro » Sat, 29 Sep 2001 08:38:38


On Thu, 27 Sep 2001 16:16:32 -0700, "John A Grandy"


>sorry. i meant to say that i need to do this using sql.

You can't. You can set the field to NOT NULL via sql, but that, of
course is different from "Allow Zero Length"

Sorry,
Bob Barrows

 
 
 

make mdb field "Allow Zero Length"

Post by John A Grand » Fri, 12 Oct 2001 04:18:18


that's what i figured. oh well.


> On Thu, 27 Sep 2001 16:16:32 -0700, "John A Grandy"

> >sorry. i meant to say that i need to do this using sql.

> You can't. You can set the field to NOT NULL via sql, but that, of
> course is different from "Allow Zero Length"

> Sorry,
> Bob Barrows

 
 
 

make mdb field "Allow Zero Length"

Post by Bob Stratto » Sat, 27 Oct 2001 00:36:53


be sure to DIM all objects WITHOUT the "New" keyword.

Dim cat As ADOX.Catalog
Dim db_TableDef As ADOX.Table
Dim db_Field As ADOX.Column

Then:

'Create your database (Catalog)
Set cat = New ADOX.Catalog
cat.Create "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Engine Type=4;Data
Source=" & DB_DSN$

' Create your table
Set db_TableDef = New ADOX.Table
With db_TableDef
 .Name = TableName$
      .ParentCatalog = cat   <==== THIS IS IMPORTANT
End With
cat.Tables.Append db_TableDef

'Create your field(s)
Set db_Field = New ADOX.Column
'Note - the variables Field_Name$, Field_Type, etc are passed in to my
routine with aappropriate values already set.
With db_Field
 .Name = Field_Name$
      .Type = Field_Type
      .DefinedSize = Field_Size
      .ParentCatalog = cat   <==== THIS ALSO IS IMPORTANT
      .Properties("Nullable").Value = True
      .Properties("Jet OLEDB:Allow Zero Length").Value = True
End With
db_TableDef.Columns.Append db_Field
'Close your field (column)
Set db_Field = Nothing

'When you're done with all the field(s) in a table,
'Close your table
Set db_TableDef = Nothing

'When you're done with all the tables in the database,
'Close the database
Set cat = Nothing

Hope it works for you too.

 
 
 

1. How to make a "decimal"-field to an "integer"-field

Hello
It is probably very easy, but I can't figure it out:
A field in a table on my MSSQL-server is at decimal-field, but in a view I
would like to use the field as an integer-field. I have tryed the SQL-code:

SELECT Int([Tabel1]![Felt2]) AS Udtryk1
FROM Tabel1;

but it dosn't work ! How do I do that ?

Thanks, Mads.

2. SELECT .. MIN() problem

3. datetime "zero" field problem

4. HELP: Referential integrity or NOT ?

5. Easy way to set 144 fields to allow zero length in code

6. New Anonymous Remailer

7. Allow Zero Length Text Fields In Access

8. Forms 3.0 message and status line can they be disabled?

9. MS Access, Add field and Allow zero length

10. How to Create field with "Allow Zero Length=Yes" with VB5 Code ?

11. aReport."Field".SetFilter("this")?

12. max of ("...","...","..")

13. Setting Allow Zero Length = "yes" in Code