Main Menu Form Will Not Open

J

Jeanette Cunningham

Post the code for this function
Public Function CMD_EnableCommandBarCtl(pcbr As CommandBar, pstrTag As
String, fEnable As Boolean) As Boolean



Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
B

Brent

Here it is

Dim ctl As CommandBarControl

On Error GoTo Err_CMD_EnableCommandBarCtl
Call RecordTrace("basCmdFunctions", "CMD_EnableCommandBarCtl", pcbr.Name)
CMD_EnableCommandBarCtl = False

Set ctl = pcbr.FindControl(msoControlButton, Tag:=pstrTag,
Visible:=True, Recursive:=True)
ctl.Enabled = fEnable

CMD_EnableCommandBarCtl = True

Exit_CMD_EnableCommandBarCtl:
Exit Function

Err_CMD_EnableCommandBarCtl:
Select Case Err
Case 91 'Control doesn't exist
CMD_EnableCommandBarCtl = True
Case Else
Call GlobalError("basCmdFunctions" & ".CMD_EnableCommandBarCtl")
End Select
Resume Exit_CMD_EnableCommandBarCtl

End Function
 
J

Jeanette Cunningham

Here is some information from a colleague. He has a download that explains
it.

CommandBarControl is a member of the Office object library. If the code uses
early binding, you will need a checked reference set to the "Microsoft
Office {version} Object Library" (mso.dll). There is a downloadable sample
available on the Seattle Access User's Group site:

A2003 uses version 11.


http://www.seattleaccess.org/downloads.htm

Quick Demo for Enabling Command UI, Zac Woodall, April 2005

Download (27 kb)

Adapted for '97 and 2000/2002, Tom Wickerath, May 2005

Download (51 kb)



Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
B

Brent

Jeanette

I got the downloads and opened them however, I'm not sure how they work, do
I copy some of the code into my code?

I can understand it you have had enough of this and want to move on.

thanks again for your help
 
J

Jeanette Cunningham

Brent, I didn't look at the downloads. I understood that they were examples.

Do this-->
Open your database and open the code window.
You are using A2003 aren't you.
Go to Tools | References
and scroll down the list till you find
Microsoft Office 11 Object Library
Check the box next to this reference then close the references dialog.
Do a compile.
Hopefully it will compile and the main menu problem will be fixed.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
B

Brent

Thanks again Jeanette for all of your help. I am going to go back to the
begining of these posts and redo everything you and others have suggested to
make sure I have not missed anything. If that doen't work I think I will be
at the end with this form and maybe try to recreate it.

Once again thanks for everything.
 
T

Tom Wickerath

Hi Brent,

Did you verify that you have a checked reference set to the "Microsoft
Office 11.0 Object Library"? Also, were you able to get the sample available
for download from the Seattle Access User's group to run okay on your PC?

Have you verified that your code compiles without any errors?


Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
__________________________________________
 
J

Jeanette Cunningham

As I understand, all your forms have this code in them. I would have thought
that all your forms would have the same problem when you try to open them.

If this was me, I would comment out the code on this main form that doesn't
work and then open the form to see if it will open.



Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
B

Brent

Jeanette

How do I comment out the code on the main form? I'm not sure if all the
forms have the same code I could check and post back.

I will post back to Tom under his post, I'm not sure if that is how it's
done or if I should post back under the last post.

Thanks again I can't believe you are still with this.
 
B

Brent

Hi Tom

Thanks for your input. At first it seemed that the office 11.0 reference was
not showing up but now I do have it. I did download the sample and I could
get it to open but I was not sure what to do with it.

Have you verified that your code compiles without any errors? I have tried
many things with the code, could you explain how this works?

Once again Thanks
 
T

Tom Wickerath

Hi Brent,
Thanks for your input. At first it seemed that the office 11.0 reference was
not showing up but now I do have it.

If you did not have this reference checked before, that would have been a
guaranteed compile-time error, as you reported earlier:

Public Function CMD_EnableCommandBarCtl
(pcbr As CommandBar, pstrTag As String, fEnable As Boolean) As Boolean

Compile error user-defined type not defined
I did download the sample and I could get it to open but I was not sure
what to do with it.

The point of that sample was to run it on your PC. It should work correctly,
without throwing any run-time errors. It includes the same type of code that
is causing you a problem in your application. So, if you received an error
with that sample, it would indicate some other problem that is unique to your
computer, but not to the .mdb file itself.
I have tried many things with the code, could you explain how this works?

Sure. Open any code module (it doesn't matter which one). Then, click on:

Debug | Compile {ProjectName}

where {ProjectName} is the name of your VBA project. You should not receive
any compile-time errors when you do this; the action should just be silent.
If you immediately go back in and click on the same sequence, without making
any changes at all to your code (including even hitting a space bar), then
you should see that this option is disabled (ie. "greyed out"). That's
exactly what you want to see.

There are two general types of VBA errors: compile-time errors and run-time
errors. If you can successfully compile your VBA code, then you've eliminated
the possibility of any compile-time errors. That doesn't mean that you are
out of the woods yet, as you may still receive a run-time error. For example,
dividing any number by zero will result in a run-time error, since division
by zero is undefined, even though such code will compile just fine.

Access MVP Crystal has a great tutorial available for you to get your feet
wet learning VBA. Check it out, here:

http://www.accessmvp.com/Strive4Peace/Index.htm


Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
__________________________________________
 
J

Jeanette Cunningham

Just post back to either tom's post or mine - we will all see it.

Now that you have that reference to the Microsoft Office 11 Object Library,
what happens when you try to open the database? If it opens and works
correctly it is fixed. Does it?

To comment out code, you put an apostrophe as the very first character at
the start of the line or lines of code.



Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top