Option Compare Database
Option Explicit
Dim strDesignAllowedForm As String
Public Sub subCheckDesignPass(strPassword As String)
Dim strForm As String, db As DAO.Database
Dim doc As DAO.Document
Set db = CurrentDb
For Each doc In db.Containers("Forms").Documents
strForm = doc.Name
If SysCmd(acSysCmdGetObjectState, acForm, strForm) <> 0 Then
If Forms(strForm).CurrentView = 0 And strForm <> strDesignAllowedForm Then
Forms(strForm).Visible = False
If InputBox("Enter Password") <> strPassword Then
DoCmd.Close acForm, strForm, acSaveYes
Else
Forms(strForm).Visible = True
strDesignAllowedForm = strForm
End If
End If
End If
Next doc
Set doc = Nothing
db.Close
Set db = Nothing
End Sub
Private Sub Form_Timer()
'set Forms' Timer Interval to value > 0
Call subCheckDesignPass("pass") ' place password here
End Sub
|