Solved

Urgent hide ribbon vba 2013

Posted on 2015-02-04
24
172 Views
Last Modified: 2016-02-10
Hi EE

In my startupform in the OnLoad event I have

Docmd.ShowToolBar "Ribbon", acToolBarNo

When I open the form in design view the Fibbon is Completely hidden. When I make an Accde and run the app I still get showing File and Home. I am not sure why this should happen. Any Help appreciated.

chestera
0
Comment
Question by:chestera
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 11
  • 7
  • 3
  • +1
24 Comments
 
LVL 23

Assisted Solution

by:Michael Fowler
Michael Fowler earned 250 total points
ID: 40590094
Run this code once to reset the properties and then retry

Function ResetStartupProperties()
    ChangeProperty "StartupForm", dbText, ""
    ChangeProperty "StartupShowDBWindow", dbBoolean, True 
    ChangeProperty "StartupShowStatusBar", dbBoolean, True
    ChangeProperty "AllowBuiltinToolbars", dbBoolean, True      
    ChangeProperty "AllowFullMenus", dbBoolean, True
    ChangeProperty "AllowBreakIntoCode", dbBoolean, True
    ChangeProperty "AllowSpecialKeys", dbBoolean, True
    ChangeProperty "AllowBypassKey", dbBoolean, True
    MsgBox "Startup Properties UnSet"
End Function

Open in new window

0
 

Author Comment

by:chestera
ID: 40590101
Michael74

Thank you michael. I will try now

Alan
0
 

Author Comment

by:chestera
ID: 40590169
Michael74

I have run function as is from a form Call ResetStartUpProperties. I get the message "Expected Procedure not Variable"

Alan
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 23

Expert Comment

by:Michael Fowler
ID: 40590206
Try running this in the immediate window

   ChangeProperty "StartupForm", dbText, ""
    ChangeProperty "StartupShowDBWindow", dbBoolean, True 
    ChangeProperty "StartupShowStatusBar", dbBoolean, True
    ChangeProperty "AllowBuiltinToolbars", dbBoolean, True      
    ChangeProperty "AllowFullMenus", dbBoolean, True
    ChangeProperty "AllowBreakIntoCode", dbBoolean, True
    ChangeProperty "AllowSpecialKeys", dbBoolean, True
    ChangeProperty "AllowBypassKey", dbBoolean, True
    MsgBox "Startup Properties UnSet"

Open in new window


Modified by SouthMod
0
 

Author Comment

by:chestera
ID: 40590219
Michael74

Thank you
0
 

Author Comment

by:chestera
ID: 40590270
Michael74

When run in immediate window I get the message "Can't Compile Module". When I go into Debug and compile the complete app I get the message "Sub or Function not Defined"

Alan
0
 
LVL 23

Expert Comment

by:Michael Fowler
ID: 40590275
In the immediate window you leave out the Function ResetStartupProperties() and End Function lines

But there is no reason why this should run
http://www.wvmitchell.com/tips/Security%20-%20locking%20down%20the%20database.htm
0
 

Author Comment

by:chestera
ID: 40590295
Michael74

Another strange problem When I open access the Home, Create, External Data, and Database tools are unchecked
If I re-check them select ok then close when I reopen they are unchecked again. I have uninstalled and then reInstalled but no change
0
 
LVL 23

Expert Comment

by:Michael Fowler
ID: 40590308
I am beginning to think that this database is corrupt.

This guide has some steps you can use to try to resolve the issue
http://www.everythingaccess.com/tutorials.asp?ID=Access-Database-Corruption-Repair-Guide
0
 

Author Comment

by:chestera
ID: 40590311
Michael74

I have tried on other dB's even created  a small testdb still the same.
With the ResetStartupProperties to ensure I am doing it correctly I create a module and enter
Function ResetStartupProperties()
    ChangeProperty "StartupForm", dbText, ""
    ChangeProperty "StartupShowDBWindow", dbBoolean, True
    ChangeProperty "StartupShowStatusBar", dbBoolean, True
    ChangeProperty "AllowBuiltinToolbars", dbBoolean, True      
    ChangeProperty "AllowFullMenus", dbBoolean, True
    ChangeProperty "AllowBreakIntoCode", dbBoolean, True
    ChangeProperty "AllowSpecialKeys", dbBoolean, True
    ChangeProperty "AllowBypassKey", dbBoolean, True
    MsgBox "Startup Properties UnSet"
End Function

Then from a form I make the call

Call RestartupProperties
0
 
LVL 23

Expert Comment

by:Michael Fowler
ID: 40590315
I am at work and cannot test but I cannot see any reason the code should not work.

I have to ask but you are calling ResetStartupProperties and not RestartupProperties
0
 

Author Comment

by:chestera
ID: 40590322
Michael74
ResetStartupProperties is correct look at the function above.
I have taken a fresh PC  new Db and I get the message Sub or Function not Defined so I created a Global variable
ChangeProperty it fixed that message but now I get "Expected Prodedure not Variable". I still think I am doing something wrong but can't see what
0
 
LVL 23

Expert Comment

by:Michael Fowler
ID: 40590346
In your post above you wrote

Then from a form I make the call

Call RestartupProperties

Which why I had to ask if you are calling ResetStartupProperties  and not RestartupProperties.
0
 

Author Comment

by:chestera
ID: 40590358
Michael74
 Yep I am using Call ResetStartupProperties . By the way I fixed the missing Ribbons. When I was using Access 2010 I used an Add on called classic Menu and some how found it's a way onto access 2013. When I removed, the missing ribbons returned
0
 
LVL 23

Expert Comment

by:Michael Fowler
ID: 40590370
Great to hear

Going forward you may still want to use this code for locking your forms
http://www.wvmitchell.com/tips/Security%20-%20locking%20down%20the%20database.htm
0
 

Author Comment

by:chestera
ID: 40590376
Michael74

I am using the correct call but still getting "Expected Procedure not Variable and it halts on ChangeProperty. If I can get it working I will use.
0
 
LVL 58
ID: 40590769
<<When I open the form in design view the Fibbon is Completely hidden. When I make an Accde and run the app I still get showing File and Home. I am not sure why this should happen. Any Help appreciated.>>

   Microsoft changed the ribbon behavior in A2013.   Unlike A2010 and prior, you can no longer fully hide the ribbon and use your own mennu bars.   Any old style menu bars appear as a tab on the ribbon.

 You'll need to write custom ribbons for any menu operations you want.

Jim.
0
 
LVL 85
ID: 40590853
I am using the correct call but still getting "Expected Procedure not Variable and it halts on ChangeProperty. If I can get it working I will use.
ChangeProperty is not a builtin Access function. It's obviously a custom function someone wrote that manipulates Properties in the database. I would not assume your db is corrupt, but rather that you're calling a function that is not present in the db.

To "fix" this, you'd need to include the ChangeProperty function, or modify the code shown to use standard VBA methods to work with Properties.
0
 
LVL 58
ID: 40590924
The ChangeProperty() function code originally appeared as part of the Access help as SetCustomProperty (posted below).

However, that's still not going to take care of your problem, as A2013 had a fundamental change in the way the ribbon is handled.

Jim.

Dim strName As String, strValue As String

' Set property name variable.
strName = "LastUserName"
' Set property value variable.
strValue = InputBox("Please enter your full name")
If SetCustomProperty(strName, dbText, strValue) <> True Then
	' Error occurred trying to set property.
	MsgBox "Error occurred trying to set property."
End If

Function SetCustomProperty(strPropName As String, intPropType _
	As Integer, strPropValue As String) As Integer

	Dim dbs As Database, cnt As Container

Dim doc As Document, prp As Property

	Const conPropertyNotFound = 3270	' Property not found error.
	Set dbs = CurrentDb					' Define Database object.
	Set cnt = dbs.Containers!Databases	' Define Container object.
	Set doc = cnt.Documents!UserDefined	' Define Document object.
	On Error GoTo SetCustom_Err
	doc.Properties.Refresh
	' Set custom property name. If error occurs here it means
	' property doesn't exist and needs to be created and appended

' to Properties collection of Document object.
	Set prp = doc.Properties(strPropName)
	prp = strPropValue					' Set custom property value.
	SetCustomProperty = True

SetCustom_Bye:
	Exit Function

SetCustom_Err:
	If Err = conPropertyNotFound Then
		Set prp = doc.CreateProperty(strPropName, intPropType, strPropValue)
		doc.Properties.Append prp		' Append to collection.
		Resume Next
	Else										' Unknown error.
		SetCustomProperty = False	

Resume SetCustom_Bye
	End If
End Function

Open in new window

0
 
LVL 85
ID: 40591161
Right - but unless you've implemented that Function in your database, the code will error out.
0
 
LVL 58
ID: 40591313
Yup.    I was just posting it here so no one had to use any links int he future.

Jim.
0
 

Author Comment

by:chestera
ID: 40592149
Scott McDaniel

Thank you Scott I thought there was more to it. Seems it wont't fix my problem anyway.

My original question  is if I put the following in tha on load event of my startup form it completely hides the ribbon when
I open that form

Docmd.ShowToolBar "Ribbon", acToolBarNo

But when I make an accde and run I get the File and Home portion of the ribbon everything else is hidden. I have a small app using a swithcboard type menu and would be good if the ribbon wasn't shown.

By the way I am using 2013



Alan
0
 
LVL 85

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 250 total points
ID: 40592474
As others have said, you cannot hide the ribbon, but you can use your own custom one. The reason you see different behavior in a compiled vs design view is ... you're in Design view, and Access acts differently than when it's in "runtime" view.
0
 

Author Comment

by:chestera
ID: 40592533
Scott McDaniel

Thanks Scott understood. I'm progressing quite well using Ribbon Creator

Alan
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question