Results 1 to 7 of 7
  1. #1
    panoss is offline Advanced Beginner
    Windows 2K Access 2003
    Join Date
    Oct 2014
    Posts
    59

    Does this code work in Access 2007?

    I 've added this code in a project.
    I have Access 2003. Works fine on my machine.
    My client has Access 2007.
    Does it work in Access 2007?
    Code:
     
            Dim i As Integer
            For i = 1 To CommandBars.Count
                CommandBars(i).Enabled = False
            Next i
            CommandBars("MyMenuBar").Enabled = True
            ChangeProperty "AppTitle", DB_TEXT, "Παραγγελίες"
            ChangeProperty "AllowFullMenus", DB_BOOLEAN, False 'Access Full Menus.
            ChangeProperty "AllowSpecialKeys", DB_BOOLEAN, False 'F11, ALT F11, etc.
            ChangeProperty "AllowBypassKey", DB_BOOLEAN, False 'Shift Key Override on loading.
            ChangeProperty "AllowShortcutMenus", DB_BOOLEAN, False 'Access Shortcut Menus. May be too severe.
            ChangeProperty "AllowBreakIntoCode", DB_BOOLEAN, False 'Code access.
            ChangeProperty "AllowBypassKey", DB_BOOLEAN, False
            ChangeProperty "StartUpShowDBWindow", DB_BOOLEAN, False
            Application.CommandBars.DisableAskAQuestionDropdown = True 'Remove the "Type a question for help"
            ChangeProperty "AllowToolbarChanges", DB_BOOLEAN, False 'Prevent Changes.
    
    
    
    Function ChangeProperty(strPropName As String, varPropType As Variant, varPropValue As Variant) As Integer
    
    Dim dbs As Object, prp As Variant
    Const conPropNotFoundError = 3270
    Set dbs = CurrentDb
    On Error GoTo Change_Err
    
    dbs.Properties(strPropName) = varPropValue
    ChangeProperty = True
    
    Change_Bye:
        Exit Function
    
    Change_Err:
    If Err = conPropNotFoundError Then ' Property not found.
        Set prp = dbs.CreateProperty(strPropName, varPropType, varPropValue)
        dbs.Properties.Append prp
    Resume Next
    
    Else
        ' Unknown error.
        ChangeProperty = False
        Resume Change_Bye
    
    End If
    
    End Function


  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    Put a STOP (red line F9) on dbs.Properties(strPropName) = varPropValue

    in debug, do: ?dbs.Properties(1)
    then 2,3, etc
    until you find your stuff.

  3. #3
    panoss is offline Advanced Beginner
    Windows 2K Access 2003
    Join Date
    Oct 2014
    Posts
    59
    You mean that I should do this in order to avoid using properties that do not exist?
    Ok, I don't mind that as long as it works.
    My worry is if it works in Access 2007 before giving it to the client.
    Thanks for your response.

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    You do know "Commandbars" were done away with in Access 2007 and later, right?

    Tried the code in A2010 and it gave a Run-time error '5' - Invalid procedure call or argument on the line
    "CommandBars("MyMenuBar").Enabled = True"

    But that might be because I don't have a "Commandbar" named "MyMenuBar". The code did disable all 210 menus. I couldn't goto form design view until I closed Access and re-opened the dB.

    Would need to have your MDB to test.

  5. #5
    panoss is offline Advanced Beginner
    Windows 2K Access 2003
    Join Date
    Oct 2014
    Posts
    59
    Ok I will post test mde.

  6. #6
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    An mde file isn't going to be much use to anyone trying to evaluate this for you. They could say 'yes' or 'no' as to whether or not it runs, but couldn't look under the hood, so to speak, to suggests tweaks to make it run if it has problems. Best to post the mdb file, instead.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  7. #7
    panoss is offline Advanced Beginner
    Windows 2K Access 2003
    Join Date
    Oct 2014
    Posts
    59
    I sent it to the client and works ok! Thank you all for your concern!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 6
    Last Post: 08-08-2014, 05:22 PM
  2. Replies: 3
    Last Post: 07-07-2014, 07:08 AM
  3. Access 2007 App Does Not Work With Runtime
    By bubba55 in forum Access
    Replies: 0
    Last Post: 09-29-2011, 08:03 PM
  4. Access 2007 report does not work in 2010
    By luppi13 in forum Reports
    Replies: 5
    Last Post: 09-07-2011, 03:05 PM
  5. 2007 Access DB won't work in 2010 - 64 bit
    By InvGrp in forum Access
    Replies: 2
    Last Post: 07-12-2010, 08:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums