I manage many databases and often need to perform some updates on all of these databases at once. I current have a small DB that I created to allow me to select a DB (mdb/mde) then perform a procedure on the selected DB.
What I really want to be able to do is to select a folder, then have code to automatically apply to the procedure to all the MDB/MDE in the selected folder. I am just not sure how to do it myself.
Following is some code I use regularly to enable/disable the ShiftByPass key.
Function EnableDisableShiftByPass(blnBypassStatus As Boolean)
' PURPOSE: Disable the shift at startup. Autoexec macro/Startup properties always executed
' INPUT PARAMETERS: Nil
On Error GoTo Err_Handler
Dim db As dao.Database
Dim prop As dao.Property
Dim strUser As String
Const conPropNotFound = 3270
Dim sDbaseName As String, MyDB As Database
strUser = Environ("USERNAME")
'Set db = CurrentDb()
If IsNull(Me.txtDatabaseFileName) = False Then
Set MyDB = OpenDatabase(txtDatabaseFileName)
MyDB.Properties("AllowByPassKey") = blnBypassStatus 'Disables/Enables the shift key on startup.
'MsgBox ("Enable set, result = " & ChangeProperty("AllowBypassKey", blnBypassStatus, True, MyDb))
If blnBypassStatus = True Then
MsgBox "Shift bypass successfully enabled " & strUser & vbCrLf
ElseIf blnBypassStatus = False Then
MsgBox "Shift bypass successfully disabled " & strUser & vbCrLf
If Err = conPropNotFound Then 'Create "AllowByPassKey" property if not exist
Set prop = MyDB.CreateProperty("AllowByPassKey", dbBoolean, blnBypassStatus)
MsgBox "Function 'EnableDisableShiftByPass' did not successfully complete." & strUser
I want to be able to apply the above code to all databases in a given folder. I already know how to capture/store the folder name in the field txtDatabaseFileName.
Any assistance would be greatly appreciated.