I want to restrict users from deleting records from a table each time the table is created. So here's my scenario..
I have created a table using the CreateTableDef Method, see below.
What I want to do is: after the table is created and data has been added, I want to make it so no data can be deleted from that table.
I can manually do that thru the "User and Group Permissions" tool. But each time my function runs it deletes that table and recreates it so I need to restablish the permissions each time. This is why I need to do it thru code. Does anyone know how to achieve this task?
I have created a table using the CreateTableDef Method, see below.
What I want to do is: after the table is created and data has been added, I want to make it so no data can be deleted from that table.
I can manually do that thru the "User and Group Permissions" tool. But each time my function runs it deletes that table and recreates it so I need to restablish the permissions each time. This is why I need to do it thru code. Does anyone know how to achieve this task?
Code:
DoCmd.DeleteObject acTable, "TrainingView"
'create recordset of training types
Set db = CurrentDb
Set rst = db.OpenRecordset("SELECT tblTrainingTypes.TrainingType " _
& "FROM tblTrainingTypes WHERE (((tblTrainingTypes.TrainingType) Is Not Null)) " _
& "ORDER BY tblTrainingTypes.TrainingType;", dbOpenSnapshot)
rst.MoveLast
rst.MoveFirst
'Create the table view
Set tdfNew = db.CreateTableDef("TrainingView")
With tdfNew
' Create fields and append them to the new TableDef
' object.
.Fields.Append .CreateField("FirstName", dbText, 155)
.Fields.Append .CreateField("LastName", dbText, 155)
.Fields.Append .CreateField("Stage", dbSingle)
Do Until rst.EOF = True
.Fields.Append .CreateField(rst!TrainingType, dbDate)
rst.MoveNext
Loop
.Fields.Append .CreateField("Location", dbText)
.Fields.Append .CreateField("UserId", dbText)
' Append the new TableDef object to the
' database.
db.TableDefs.Append tdfNew
End With