Error with hide ribbon command

scottb
4StarLounger
Posts: 402
Joined: 14 Apr 2010, 15:59

Error with hide ribbon command

Post by scottb »

I have used the following on numerous other projects without issue. For some reason I have a form that I am trying to use the on open event to hide the ribbon bar by way of :
Private Sub Form_Open(Cancel As Integer)
DoCmd.Maximize
DoCmd.ShowToolbar "Ribbon", acToolbarNo
End Sub

It generates an on open error. I tried it with and without maximize and also as an on load event with the same error result. Has anyone seen this? It worked previously and I can't seem to find what the problem is.
Thank you.
-Scott

User avatar
HansV
Administrator
Posts: 78487
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Error with hide ribbon command

Post by HansV »

I've never seen that. What is the text of the error message?
Best wishes,
Hans

scottb
4StarLounger
Posts: 402
Joined: 14 Apr 2010, 15:59

Re: Error with hide ribbon command

Post by scottb »

I received the following:
"The expression On Load you entered as the event property setting produced the following error: Sub or Function not defined."
Haven't seen this one before with that line of code.
Thanks Hans.

User avatar
HansV
Administrator
Posts: 78487
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Error with hide ribbon command

Post by HansV »

Weird. Have you checked Tools | References... in the Visual Basic Editor for missing references?
Best wishes,
Hans

User avatar
HansV
Administrator
Posts: 78487
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Error with hide ribbon command

Post by HansV »

One other thing - has this database originally been created in Access 2003 or before (i.e. pre-Ribbon)?
Best wishes,
Hans

scottb
4StarLounger
Posts: 402
Joined: 14 Apr 2010, 15:59

Re: Error with hide ribbon command

Post by scottb »

The form I am having trouble with was imported from a 2003 db. Everything else built new in 2010.

scottb
4StarLounger
Posts: 402
Joined: 14 Apr 2010, 15:59

Re: Error with hide ribbon command

Post by scottb »

Mindful of that, I will try to recreate the form native in 2010 to see if resolved. Simple enough.

scottb
4StarLounger
Posts: 402
Joined: 14 Apr 2010, 15:59

Re: Error with hide ribbon command

Post by scottb »

Recreated my form and the error went away. Thanks for point me in the right direction . :-)

User avatar
HansV
Administrator
Posts: 78487
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Error with hide ribbon command

Post by HansV »

Phew - it was just a wild guess...
Best wishes,
Hans

scottb
4StarLounger
Posts: 402
Joined: 14 Apr 2010, 15:59

Re: Error with hide ribbon command

Post by scottb »

Historically your guesses have been much better than mine :-)
Thank you Hans.