Adox default value for column

Posted on 2003-02-27
Medium Priority
Last Modified: 2008-03-03
I am using ADOX (on Windows 2000) to create a new table in my database.

One of the columns must have a default for each new record so I wish to
populate the default dynamic property.

However, I cannot do this because when I try to set the value of the
default property I am told the data type is wrong (it is expecting

Set adoxCatalog.ActiveConnection = ADOCon
Set adoxTable = New adox.Table
adoxTable.Name = "MyNewTable"

Set adoxCol = New adox.Column
Set adoxCol.ParentCatalog = adoxCatalog
adoxCol.Name = "MyNewColumn"
adoxCol.Type = adInteger
adoxCol.Attributes = adColFixed
adoxCol.Properties("Default").Value = 0   ' this line fails
adoxTable.Columns.Append adoxCol

Question by:Victoria_
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment

Accepted Solution

QJohnson earned 300 total points
ID: 8034888
Only two things come to mind. First, try:

adoxCol.Properties("Default").Value = CVar(0)

since the default property is supposed to expect a variant and perhaps it has a hard time with literal integer.

On the second issue, I may be off-base, but I thought the adColFixed attribute was only for use on character fields whose width can vary.  Since you have an integer field here, perhaps you should just try commenting that line out.

What version of ADOX are you using?  I never got the data type error complaint until I executed the cat.Tables.Append statement - and then had to visit the data type of every column to try and figure out which one caused the problem.  This is pretty nice if it has changed and can actually show you the offending one now.


Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month15 days, 7 hours left to enroll

741 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question