Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

can I make entire database read-only ??

Status
Not open for further replies.
Jan 14, 2002
143
0
0
US
Hello,

I need to make ALL my forms read-only when a user re-links to an "archive" database.

Since all of the forms need to be read-only, it doesn't make sense to have to figure out what forms are open and then reset its RecordSetType. There must be a more efficient (and less exhaustive) way to do it all in one whack.

I tried using the AllForms property to loop through all forms that are open and set them to read-only, but it doesn't work because apparently the embedded forms need a complete form reference.


Any help is appreciated.

Thanks,
Blaine


 
Consider using Access built-in security--you can set it so that your "Archive" database tables are read-only to users. This is a pretty much bulletproof way to ensure all of the data is left untouched. Watch out, though, if you use temporary tables to build reports, etc because you WILL have to be able to add/edit those.

--
Find common answers using Google Groups:

Corrupt MDBs FAQ
 
another method is to loop through MsysObjects, open all forms, reset the AllowAddition, AllowDeletion, AllowEdit properties to False, then close them (except the one you are in).

Private Sub cmdAllowEdit_Click()
Dim frm As Form, strName As String
Dim db As DAO.Database, rst As DAO.Recordset
Set db = CurrentDb
Set rst = db.OpenRecordset("MsysObjects")
With rst
.MoveFirst
Do While Not .EOF
If rst!Type = -32768 Then
DoCmd.OpenForm rst!Name, acDesign, , , , acHidden
End If
.MoveNext
Loop
End With
For Each frm In Forms
With frm
.AllowAdditions = True
.AllowDeletions = True
.AllowEdits = True
End With
DoCmd.Save acForm, frm.Name
Next frm
For Each frm In Forms
If frm.Name <> &quot;frmTest&quot; Then
DoCmd.Close acForm, frm.Name
End If
Next frm
End Sub

Private Sub cmdNoEdit_Click()
Dim frm As Form, strName As String
Dim db As DAO.Database, rst As DAO.Recordset
Set db = CurrentDb
Set rst = db.OpenRecordset(&quot;MsysObjects&quot;)
With rst
.MoveFirst
Do While Not .EOF
If rst!Type = -32768 Then
DoCmd.OpenForm rst!Name, acDesign, , , , acHidden
End If
.MoveNext
Loop
End With
For Each frm In Forms
With frm
.AllowAdditions = False
.AllowDeletions = False
.AllowEdits = False
End With
DoCmd.Save acForm, frm.Name
Next frm
For Each frm In Forms
If frm.Name <> &quot;frmTest&quot; Then
DoCmd.Close acForm, frm.Name
End If
Next frm
End Sub


PaulF
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top