Solved

Urgent hide ribbon vba 2013

Posted on 2015-02-04
24
161 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
  • 11
  • 7
  • 3
  • +1
24 Comments
 
LVL 23

Assisted Solution

by:Michael74
Michael74 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
 
LVL 23

Expert Comment

by:Michael74
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:Michael74
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:Michael74
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:Michael74
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 23

Expert Comment

by:Michael74
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:Michael74
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 57
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 84
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 57
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 84
ID: 40591161
Right - but unless you've implemented that Function in your database, the code will error out.
0
 
LVL 57
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 84

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

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
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…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

758 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now