This might help you to get a handle on the documents collection & see what you've got defined. I suggest running this to ensure you haven't deleted anything important:
Code:
Sub getDocuments()
Dim n As Long
'documents collection is zero based, so subtract 1 from the count
For n = 0 To CurrentDb.Containers("databases").Documents.Count - 1
Debug.Print CurrentDb.Containers("databases").Documents(n).Name
Next
End Sub
The code that follows is how I've done it in the past for the AllowBypassKey property. I suppose you could include the function part within a sub, but for me, when something is going to get called often and has two or more modes, I tend to put it in its own function in a module (library) of functions - helps me to find them as opposed to searching everywhere. Obviously, you would not use the part where the sub manipulates the form, but your own code instead.
Code:
Sub SetBypassProp()
Dim db As DAO.Database
Dim prop As DAO.Property
Dim bolMode as Boolean
On Error GoTo errHandler
Set db = CurrentDb
Set prop = db.Properties("AllowByPassKey")
'Note to mks123 - in the sample I'm copying from, I get the user level from my user object and if 'admin'
'I allow this property to cycle, then I change a main form label to red to alert me that it's enabled in case
'I forget to disable it before releasing a new front end
If prop = True Then 'bypass enabled; change it to false
bolMode = False 'pass this change to the function
prop = apDisableShift(bolMode) 'property value becomes the function value
DoCmd.SelectObject acForm, "frmSwtchbrd"
Forms!frmSwtchbrd.lblVersion.ForeColor = RGB(255, 255, 255)
Else: 'assume prop is false - can only be either true or false
mode = True 'pass this change to the function
prop = apDisableShift(bolMode) 'property value becomes the function value
DoCmd.SelectObject acForm, "frmSwtchbrd"
Forms!frmSwtchbrd.lblVersion.ForeColor = RGB(255, 0, 0)
End If
MsgBox "Enable bypass is now " & prop 'let admin know the property was changed
Set db = Nothing
Set prop = Nothing
Exit Sub
errHandler:
If Err.Number = 3270 Then 'bypass property doesn't exist so create it
Set prop = db.CreateProperty("AllowByPassKey", dbBoolean, False)
db.Properties.Append prop
Resume
End If
End Sub
Code:
Function apDisableShift(Mode) As Boolean
CurrentDb.Properties("AllowByPassKey") = mode
apDisableShift = mode
End Function
Not sure how possible it would be to get stuck in a loop with Resume - never happened to me.
I'll have to play with the user defined property to see how/if I can use this approach - I'm not familiar with that object model or its error trapping. Will try to post something along that line tomorrow.