Stuart McLachlan
stuart at lexacorp.com.pg
Wed May 21 00:58:55 CDT 2014
Folowing on from Rocky's AppTitle problem and my mention of SetProperties, here's my standard method for locking down a FE: 1. I have an Autoexec Macro which calls a Startup() function 2. One line of the Startup Function is "LockDown True" 3. On my main menu form, I have a label with my Copyright notice. The DoubleClick event for that label contains the line "LockDown False". I have the two functions below in a code module. So every time the application is opened, the "control properties" such as AllowBYpassKey is set to false and users can't get into anything. If I double click on the copyright notice, I can close the application and re-open it with the Shift Key held down to get into everything. Once I have finished working in it, I close it and re-open it and everything is locked once more. Function Lockdown(state As Boolean) SetProperties "AllowBypassKey", dbBoolean, Not state SetProperties "AllowFullMenus", dbBoolean, Not state SetProperties "AllowSpecialKeys", dbBoolean, Not state SetProperties "AllowToolbarChanges", dbBoolean, Not state SetProperties "AllowBuiltInToolbars", dbBoolean, Not state SetProperties "AllowBreakIntoCode", dbBoolean, Not state SetProperties "AllowSHortcutMenus", dbBoolean, Not state End Function Public Function SetProperties(strPropName As String, _ varPropType As Variant, varPropValue As Variant) As Integer On Error GoTo Err_SetProperties Dim db As DAO.Database, prp As DAO.Property Set db = CurrentDb db.Properties(strPropName) = varPropValue SetProperties = True Set db = Nothing Exit_SetProperties: Exit Function Err_SetProperties: If Err = 3270 Then 'Property not found Set prp = db.CreateProperty(strPropName, varPropType, varPropValue) db.Properties.Append prp Resume Next Else SetProperties = False MsgBox "SetProperties", Err.Number, Err.Description Resume Exit_SetProperties End If End Function On 21 May 2014 at 1:14, Bill Benson wrote: > Should one have this instead? > > ' Attempt to set the specified property. > On Error GoTo Err_Property > dbsTemp.Properties(strName) = varSetting > Set dbsTemp.Properties(strName) = varSetting > On Error GoTo 0 > > I doubt with error handling like this, that it could hurt... > > Or are the properties *never* required to be "SET"? > > -----Original Message----- > From: accessd-bounces at databaseadvisors.com > [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Heenan, > Lambert Sent: Tuesday, May 20, 2014 12:31 PM To: 'Access Developers > discussion and problem solving' Subject: Re: [AccessD] AppTitle > Property > > "SetPropterty" - It's a UDF. Here is the code... > > Private Sub SetProperty(dbsTemp As Database, strName As String, > conType As DataTypeEnum, varSetting As Variant) ' Parameters: > ' dbsTemp - an initialized Database Object ' strName - the name of the > property ' conType - the type of the property, e.g. dbBoolean, dbText > etc. ' varSetting - the value to set the property to > > Dim prpNew As Property > Dim errLoop As Error > > ' Attempt to set the specified property. > On Error GoTo Err_Property > dbsTemp.Properties(strName) = varSetting > On Error GoTo 0 > > Exit Sub > > Err_Property: > > ' Error 3270 means that the property was not found. > If DBEngine.Errors(0).Number = 3270 Then > ' Create property, set its value, and append it to the > ' Properties collection. > Set prpNew = dbsTemp.CreateProperty(strName, _ > conType, varSetting) > dbsTemp.Properties.Append prpNew > Resume Next > Else > ' If different error has occurred, display message. > For Each errLoop In DBEngine.Errors > MsgBox "Error number: " & errLoop.Number & vbCr & _ > errLoop.Description > Next errLoop > End > End If > > End Sub > > Lambert > > -----Original Message----- > From: accessd-bounces at databaseadvisors.com > [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Rocky > Smolin Sent: Tuesday, May 20, 2014 8:51 AM To: 'Access Developers > discussion and problem solving' Subject: Re: [AccessD] AppTitle > Property > > Stuart: > > What is SetProperties? Does not compile. And what should value of > varPropValue be for "AppTitle" > > TIA > > Rocky > > > -----Original Message----- > From: accessd-bounces at databaseadvisors.com > [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Stuart > McLachlan Sent: Monday, May 19, 2014 4:14 PM To: Access Developers > discussion and problem solving Subject: Re: [AccessD] AppTitle > Property > > Generally, database properties in Access do not exist until they are > set for the first time. > > Set it either with the Options - Current Database (or whatever it was > in 2003 > > or in VBA with something like: > > Dim db As DAO.Database, prp As DAO.Property > Set db = CurrentDb > db.Properties(strPropName) = varPropValue > SetProperties = True > Set db = Nothing > > -- > Stuart > > On 19 May 2014 at 16:01, Rocky Smolin wrote: > > > Dear List: > > > > I had a 2003 mdb with a problem - not important what it was - had to > > do with odd mouse behavior in design view. > > > > Anyway, I imported all the objects into a blank mdb and everything > > works better except: > > > > lblVersion.Caption = "Version " & > > Right(CurrentDb.Properties("AppTitle"), _ > > Len(CurrentDb.Properties("AppTitle")) - 46) > > > > works perfectly in the previous version and all versions of this app > > going back to day 1. > > > > In this new one it throws the error 3270 - Property Not Found. > > > > Checked the references - identical between the two mdbs. > > > > Any idea what to look for next? > > > > MTIA > > > > Rocky > > > > -- > > AccessD mailing list > > AccessD at databaseadvisors.com > > http://databaseadvisors.com/mailman/listinfo/accessd > > Website: http://www.databaseadvisors.com > > > > > -- > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com > > -- > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com > > -- > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com > > -- > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com >