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
<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.
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
Sorry,
Bob Barrows
> >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
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.
3. datetime "zero" field problem
4. HELP: Referential integrity or NOT ?
5. Easy way to set 144 fields to allow zero length in code
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")?
13. Setting Allow Zero Length = "yes" in Code