ADO Question

u0107

Board Regular
Joined
Dec 18, 2002
Messages
154
Hello,

I have an array from which I load values into a table.

My table creation is done using ADO.

Some of the fields in the Array can have null values and I want to load the corresponding table field with the same values as in the array - that is null or non-null values.

I have defined text fields in ADO in table creation as follows:

With tbl
.Name = "tbl_Name"
Set .ParentCatalog = cat
.Columns.Append "Case_Field", adWChar
End With

When the array contains null values I get a message saying
"You tried to assign a Null Value for a variable that is not Variant Data Type"

What should I change "adWChar" to in order that this message does not appear?

Thanks in advance.

Uttam
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Total shot in the dark here (untested), but try setting it to vbNull. Maybe that will work...
 
Upvote 0
I found the solution to the problem Myself:

After all the .column.append statements,

I located the field index of the field in which I wanted to allow nulls and incorporated the following line in my code:

tbl.Columns.Item(6).Properties.Item(3).Value = True

In the above, Item(6) refers to the field in which I want to have Null values. And in the properties Item(3) refers to a property "adNullable". It was having an empty value which I changed to "True" by means of the above statement immediately after the .column.append statements.

Hope this helps others who have a similar problem.

Cheers!
 
Upvote 0

Forum statistics

Threads
1,221,574
Messages
6,160,602
Members
451,657
Latest member
Ang24

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top