' This procedure will clear all the cells in the InstructorAllocations table
Private Sub Command0_Click()
Dim curDatabase As Database
Set curDatabase = CurrentDb
Dim rstInstructorsAllocations As Object
Dim F As Integer
Dim t As Integer
Dim p As Integer
F = 8 'Field number or position. 0 is the 1st position
p = 1 'Field name in "InstructorsAllocations" table
' Because the fields with data type Date/time do not accept the null value "", the following will
' Convert columns with type Date/time to text so that it can accept the null value "".
' On completion the fields must be converted back to the original Date/time data type.
'curDatabase.Execute ("ALTER TABLE UniqueCoursesUnderClasses ALTER COLUMN " & p & " TEXT") 'Change data type to text
Set rstInstructorsAllocations = curDatabase.OpenRecordset("UniqueCoursesUnderClasses")
t = rstInstructorsAllocations.RecordCount
Dim j, i As Integer
For j = 1 To 15
For i = 1 To t
rstInstructorsAllocations.Edit
rstInstructorsAllocations.Fields(F) = vbNull ' Set fields to null
rstInstructorsAllocations.Update
rstInstructorsAllocations.MoveNext
Next i
' Change data type back to date type
Set rstInstructorsAllocations = Nothing
' curDatabase.Execute ("ALTER TABLE UniqueCoursesUnderClasses ALTER COLUMN " & p & " DATETIME")
F = F + 1
p = p + 1
' curDatabase.Execute ("ALTER TABLE UniqueCoursesUnderClasses ALTER COLUMN " & p & " TEXT")
Set rstInstructorsAllocations = curDatabase.OpenRecordset("UniqueCoursesUnderClasses")
Next j
Set curDatabase = Nothing
MsgBox "Successfully completed"
End Sub