Windows 7 - Main Menu Form Will Not Open

Asked By Brent on 07-Aug-09 03:35 PM
I have just converted a database from version 97 / 2000 to MS Access 2003.
The Main menu form will not open, I get a message that I must convert to a
newer version that 97 / 2000 and then it closes the database down. I have
converted the database. This is the only form that will not open. I open the
database using the shift key and the main form will open in design view. Can
someone help with this problem?

Thanks




Jeanette Cunningham replied on 07-Aug-09 10:26 PM
Hi Brent,
When you have the database open and the main form open in design view, open
the code window and check the references.
You will need to select the Microsoft DAO 3.6 Object Library as a reference.
After you set that reference and close the references dialog, do a compile
and fix any errors until the code compiles.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
Brent replied on 08-Aug-09 12:04 PM
Thanks Jeanette
When I opened the code and check the references the Microsoft DAO 3.6 Object
Library was already checked, I compacted and repaired a few times and the
result is the same, the Main Menu Form will not open it still thinks I have
not converted to a newer version. Could there be something in the code
somewhere that is causing this? if so where can i find it?
Jeanette Cunningham replied on 08-Aug-09 06:14 PM
The next problem with A2000 is that it had many service packs - do you have
them all installed?

The next thing to check is the code.
What code do you have when the database opens?
Is there an autoexec macro?
What code is on the main menu form?

One way to test the code is a method like this that I have used-->
Open your database with the shift key.
Open the main form in design view and put break points on the subs and
functions.
Close the main form.
Now open the main form in form view from the database window.
When the code window opens, step through the code.
Note the first error. I do not recommend making any changes to code in break
mode, so stop the code and then fix the code.
Keep testing and fixing until it works.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
Gina Whipp replied on 08-Aug-09 07:35 PM
Brent,

Things I would check...

1.  Please list the References you have set and the order in which they
appear.  Because Access 97 had some References that were unnecessary to
future versions, once you post what you have one or two may need to be
eliminated to 'fix' the Main Menu.

2.  Make sure at the top of every module appears...

Option Explicit
Option Compare Database

This will insure the are no undeclared variables that are causing the
problem.

3.  Go into an module window and Debug - Complie and fix any errors that
might appear.

--
Gina Whipp

II

http://www.regina-whipp.com/index_files/TipList.htm
Brent replied on 09-Aug-09 03:24 PM
First of all thanks to Jeanette and Gina for your help with this problem.

I will start with listing the References I have checked in order from first
to last:

1. Visual Basic for Applications
2. Microsoft Access 10.0 object Library
3. OLE Automation
4. Microsoft DOA 3.6 Object Library
5. Microsoft Active X Data Object 2.5 Library

Now I will try some of the other suggestions and this may take some time as
I am not good with Modules and code issues.

I will post back results or if I have problems with the codes
Brent replied on 09-Aug-09 03:52 PM
Here is me first debug problem that is identified

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

This shows up in each Module I debug. Does this help or is their more to
this that I need to post?
Jeanette Cunningham replied on 09-Aug-09 04:59 PM
Is this function the spot where the compiler stops and gives an error?
What error does it give?


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
Gina Whipp replied on 09-Aug-09 07:06 PM
Brent,

Is this the line that is highlighted in yellow?   Also, copy/paste the rest
of the module here.

--
Gina Whipp

II

http://www.regina-whipp.com/index_files/TipList.htm
Gina Whipp replied on 09-Aug-09 07:09 PM
Brent,

Did you convert this database to Access 2003?  Because according to the
Object Library you did not.  So perhaps the better question is what version
is your databse?

--
Gina Whipp

II

http://www.regina-whipp.com/index_files/TipList.htm
Brent replied on 09-Aug-09 07:30 PM
Hi Jeanette

This is where the compiler stops when I run debug on the Modules of the
database that I have converted to 2003. It just stops on this line and does
not give an error message.

Re: your previous message:
I do not have Access 2000 on my computer anymore

The next thing to check is the code.
What code do you have when the database opens? It tell me Microsoft access
can not find  the macro "mnuMain" I lkkoed and there are no macros in this
database not ever Auotexec macro
Is there an autoexec macro?
What code is on the main menu form? Do you want me to post all of the code I
found for the form? it is long.
How do I put break points on the subs and functions?

Gina asked that on the top of every module had
Option Explicit
Option Compare Database

Yes they do however they are in reverse order, does this matter?

Thanks again for all your help. This post maybe confusing, let me know
Brent replied on 09-Aug-09 10:08 PM
Gina

Yes, I did convert the database to 2003 but that seems to be the problem the
database done not think I have. It keeps asking for me to use a newer program
97 or newer and I am.
Brent replied on 09-Aug-09 10:21 PM
Gina


There is no yellow highlighted line the line above was in blue

Also, copy/paste the rest of the module here. This is from the form code


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

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 does not exist
CMD_EnableCommandBarCtl = True
Case Else
Call GlobalError("basCmdFunctions" & ".CMD_EnableCommandBarCtl")
End Select
Resume Exit_CMD_EnableCommandBarCtl

End Function

Hope this helps
Jeanette Cunningham replied on 09-Aug-09 10:21 PM
Option Explicit
Option Compare Database

should be in the order

Option Compare Database
Option Explicit


-------------------------
macros - that is fine. You have checked for macros and there are no macros.
That is one less thing to check for errors.

----------------------

About converting to A2003
One easy way that I do conversions is to create a new blank database in the
newer version and be sure to set 'Track Name Auto correct' to No.
So create a new blank database in A2003, go to Tools | Options | General tab
and set Track name autocorrect to no.

Do you have linked tables?
If you do, use the new blank database you just created and import the tables
into it (do not link them).

Then create another new blank database for the front end.
Link the tables to the new database, then import all the other objects -
queries, forms  etc.

If you do not have linked tables, just create one new database as described
above.
Import everything from the 97 database to the new one.

After you finish the import do a compile.
Check for the correct references.

You will now have an A2003 version of your database and can continue on with
fixing any errors.




Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
Gina Whipp replied on 10-Aug-09 01:06 AM
Brent,

Jeanette has a great idea which is import your objects into a new clean 2003
database.  Read her post and follow those directions and see if the problem
persists.

--
Gina Whipp

II

http://www.regina-whipp.com/index_files/TipList.htm
Brent replied on 14-Aug-09 03:57 PM
Hi Jeanette

Sorry for not getting back sooner but work got in the way.

Now that I have converted the database what should the new references be? it
looks like I still have the same old ones.

I now get this new error message

Microsoft can not find the macro "mnuMain" the macro groups do not exist or
it is new and has not been saved, then it talks about the macorgroup that was
saved
I must specify the same macroname in the argument???

Any ideas on this?
Jeanette Cunningham replied on 14-Aug-09 07:50 PM
There are 3 references you need for A2003
Visual basic for applications
Microsoft Access 11.0 Object Library
Microsoft DAO 3.6 Object Library

When you imported all the objects, you may have ommitted the menus.
Go back to the import screen and under options select Menus and Toolbars.
Don't select any tables, queries etc, just the menus and toolbars.
See if this fixes the problem.

What is the name of the form that should open when the database opens?
Have you put this form as the startup form in the database options | Tools |
Startup
Display Form/Page:


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
Brent replied on 16-Aug-09 06:31 PM
Hi Jeanette

Here is the code where the yellow highlight starts, I just found it. Do you
see anything in the code that is causing the problem? It looks to me like
there might be something here as it tells to stop application if !!!! The
form is in the startup

Public Function APPL_StartApplication() As Boolean

Dim fldEntityName       As Field
Dim fldEntityPath       As Field
Dim intI                As Integer
Dim lngNumDatabases     As Long
Dim qdfEntity           As QueryDef
Dim rstEntity           As Recordset
Dim strMsg              As String

On Error GoTo Err_APPL_StartApplication
Call RecordTrace("basApplFunctions", "APPL_StartApplication")
APPL_StartApplication = False

TryRelink:
Set rstEntity = Nothing
If CMD_GetVersion() < "8.0" Then
strMsg = gconSystemTitle & " must be run with Microsoft Access 97 or
later"
MsgBox strMsg, vbOKOnly + vbCritical, gconSystemTitle
Application.Quit A_EXIT
End If

Set gwrk = DBEngine.Workspaces(0)
Set gdb = CurrentDb

Set qdfEntity = gdb.QueryDefs("qselEntityDatabases")
Set rstEntity = qdfEntity.OpenRecordset
With rstEntity
.MoveLast
.MoveFirst
lngNumDatabases = .RecordCount
Set fldEntityName = .Fields("EntityName")
Set fldEntityPath = .Fields("EntityPath")
End With
ReDim gdbLinked(1 To lngNumDatabases)
intI = 0
With rstEntity
.MoveFirst
Do While Not .EOF
intI = intI + 1
Set gdbLinked(intI) = DBEngine.OpenDatabase(fldEntityPath & "\"
& fldEntityName)
.MoveNext
Loop
.Close
End With

'Set startup properties of database
If CMD_IsItMDE(CurrentDb) Then
Call CMD_SetStartupProperties
End If

APPL_StartApplication = True

Exit_APPL_StartApplication:
Exit Function

Err_APPL_StartApplication:
Select Case Err.Number
Case 3044, 3051, 3043
MBX_Ok "Unable to open the database " & fldEntityPath & "\" &
fldEntityName
If Not CMD_OpenForm("frmEntitymaintenance",
plngWindowMode:=acDialog) Then Resume Exit_APPL_StartApplication
Resume TryRelink
Case 10001 'Error in called procedure
Case Else
Call GlobalError("basApplFunctions" & ".APPL_StartApplication")
End Select
Resume Exit_APPL_StartApplication

End Function

Thanks again for all your help
Jeanette Cunningham replied on 16-Aug-09 09:31 PM
Here are the steps to debug this code:
Find the line   Call RecordTrace("basApplFunctions",
and click in the very far left margin for this line to set a break point -
when it is set you will see the whole line coloured red.
Save and close the code window.
Close the startup form if it is open.
Now open the startup form.
The code will stop at the break point you set.
Now press F8 to step through the code.


Post back with results.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
Brent replied on 16-Aug-09 10:11 PM
Jeannette

Here is the first place the code stoped at I pressed F8

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

Compile error user-defined type not defined

I can not proceed pass this line.

Thanks
Jeanette Cunningham replied on 17-Aug-09 02:04 AM
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
Brent replied on 17-Aug-09 09:21 AM
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 does not exist
CMD_EnableCommandBarCtl = True
Case Else
Call GlobalError("basCmdFunctions" & ".CMD_EnableCommandBarCtl")
End Select
Resume Exit_CMD_EnableCommandBarCtl

End Function
Jeanette Cunningham replied on 18-Aug-09 01:18 AM
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
Brent replied on 18-Aug-09 10:49 PM
Jeanette

I got the downloads and opened them however, I am 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
Jeanette Cunningham replied on 19-Aug-09 12:17 AM
Brent, I did not look at the downloads. I understood that they were examples.

Do this-->
Open your database and open the code window.
You are using A2003 are not 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
Brent replied on 23-Aug-09 06:41 PM
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.
Tom Wickerath replied on 23-Aug-09 09:17 PM
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/
__________________________________________
Jeanette Cunningham replied on 23-Aug-09 11:03 PM
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 does not
work and then open the form to see if it will open.



Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
Brent replied on 26-Aug-09 09:59 PM
Jeanette

How do I comment out the code on the main form? I am 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 am not sure if that is how it is
done or if I should post back under the last post.

Thanks again I cannot believe you are still with this.
Brent replied on 26-Aug-09 10:05 PM
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
Tom Wickerath replied on 27-Aug-09 12:19 AM
Hi Brent,


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


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.


Sure. Open any code module (it does not 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 have eliminated
the possibility of any compile-time errors. That does not 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/
__________________________________________
Jeanette Cunningham replied on 27-Aug-09 08:19 PM
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