Hi,
I currently have it so that you enter a name in a text box, that then creates it as a field in a table using the append command. I would like it to do one of many different things all aiming for the same goal.
I want it to either, make the new field as a check box field, if you cant do that, create the field with the append with all of the cells containing "false" or finally which is what i was attempting to do, create the table and then using a recordset fill in each cell with a value, such as false. Here is my code, any further help will be immenseley appreciated.
Private Sub Command28_Click()
Dim dbsTables As Database
Set dbsTables = OpenDatabase("C:\marketing_database_new.mdb")
Dim tdftblONE As TableDef
Set tdftblONE = dbsTables.TableDefs!ContactInfo
NewOne = txtNewCatalogue
NewOneDelivered = NewOne + "_Delivered"
AppendDeleteField tdftblONE, "APPEND", _
NewOne, vbBoolean, 50
AppendDeleteField tdftblONE, "APPEND", _
NewOneDelivered, vbBoolean, 50
Debug.Print "Fields after Append"
Debug.Print , "Type", "Size", "Name"
dbsTables.Close
MsgBox "Patch Succeeded", vbOKOnly
End Sub
Sub AppendDeleteField(tdfTemp As TableDef, _
strCommand As String, strName As String, _
Optional varType, Optional varSize)
With tdfTemp
If .Updatable = False Then
MsgBox "TableDef not Updatable! " & _
"Unable to complete task."
Exit Sub
End If
If strCommand = "APPEND" Then
.Fields.Append .CreateField(strName, _
varType, varSize)
Else
If strCommand = "DELETE" Then .Fields.Delete _
strName
End If
End With
End Sub
I currently have it so that you enter a name in a text box, that then creates it as a field in a table using the append command. I would like it to do one of many different things all aiming for the same goal.
I want it to either, make the new field as a check box field, if you cant do that, create the field with the append with all of the cells containing "false" or finally which is what i was attempting to do, create the table and then using a recordset fill in each cell with a value, such as false. Here is my code, any further help will be immenseley appreciated.
Private Sub Command28_Click()
Dim dbsTables As Database
Set dbsTables = OpenDatabase("C:\marketing_database_new.mdb")
Dim tdftblONE As TableDef
Set tdftblONE = dbsTables.TableDefs!ContactInfo
NewOne = txtNewCatalogue
NewOneDelivered = NewOne + "_Delivered"
AppendDeleteField tdftblONE, "APPEND", _
NewOne, vbBoolean, 50
AppendDeleteField tdftblONE, "APPEND", _
NewOneDelivered, vbBoolean, 50
Debug.Print "Fields after Append"
Debug.Print , "Type", "Size", "Name"
dbsTables.Close
MsgBox "Patch Succeeded", vbOKOnly
End Sub
Sub AppendDeleteField(tdfTemp As TableDef, _
strCommand As String, strName As String, _
Optional varType, Optional varSize)
With tdfTemp
If .Updatable = False Then
MsgBox "TableDef not Updatable! " & _
"Unable to complete task."
Exit Sub
End If
If strCommand = "APPEND" Then
.Fields.Append .CreateField(strName, _
varType, varSize)
Else
If strCommand = "DELETE" Then .Fields.Delete _
strName
End If
End With
End Sub