Hey people - got a big computing project due in tuesday. any help would be much appreciated! ;)
I haven't found the code above to work for making a column in access nullable! originally my field type was adcurrency and I changed it to advarwchar, but same error occurs!
I'm using Jet 4.0:
Private Sub cmdAddToday_Click()
Dim DBtable As Table Dim DBcatalogue As New ADOX.Catalog
Dim Today As String
Dim ColumnCount As Integer
Dim NewColumnIndex As Integer
Dim Counter As Integer
Dim blnCheck As Boolean
Dim strCurrent As String
strCurrent = Me.adoSecurities.Recordset.Fields("SEDOLNumber")
Today = Format(Date, ShortDate)
DBcatalogue.ActiveConnection = _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=pmp.mdb"
Me.dgdPrices.ReBind
Me.dgdPrices.Refresh
Set DBtable = DBcatalogue.Tables("tblsecurity")
ColumnCount = DBtable.Columns.Count
For Counter = 0 To (ColumnCount - 1)
If DBtable.Columns(Counter).Name = Today Then
blnCheck = True
Exit For
Else
blnCheck = False
End If
Next Counter
If blnCheck = True Then
MsgBox "A field already exists for today's date", vbExclamation, "Error"
Me.cmdAddToday.Enabled = False
Else
DBtable.Columns.Append (Today), adVarWChar, 6
With DBtable.Columns.Item(Today)
Set .ParentCatalog = DBcatalogue
.Properties("Jet OLEDB:Allow Zero Length") = True
.Properties("Nullable") = True
End With
'N.B. Microsoft Access ODBC driver doesn't provide programmatic means of determining nullability property of column in table (
http://support.microsoft.com/default...b;en-us;185823) Hence, field added has default property set to 'required' thus preventing adding of new records
The problem (according to MS) has been fixed with Jet 4.0, but this is not the case.
Can anyone help?