Link to home
Start Free TrialLog in
Avatar of bc4942
bc4942

asked on

How to programmatically switch query to design mode

I have an Access databas that does not allow objects like forms and tables to be modified in design mode.  I just added the default Access buttons to allow users to create custom data queries.  If a new query is created and run, but not yet saved, Access recognizes it as "query1" and that is fine.  

The problem is once the query is run and you are looking at the data, one might decide to modify the query further, but I can find no way to get back to design mode without adding the default Access design mode button.  The problem with that is that it would then allow users to switch forms, reports, tables, etc in the database to design mode!

I need a way to only switch the query to design mode!
ASKER CERTIFIED SOLUTION
Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bc4942
bc4942

ASKER

The problem is just are when you are designing a query in Access, the query may not be saved to the database.  Therefore, how would I use:
docmd.OpenQuery "YourQuery",acViewDesign
if the query has not been saved and therefore technically has no name.
You couldn't ... you'd have to save the query, then open it in Design view.
Avatar of bc4942

ASKER

So then how does Access do it using the default "design mode" button.  With it, you can switch back and forth from design to actually running the query even though the new query has not been saved yet.
I would suppose it builds a temporary query and allows you to work with that. That's typically the way object-oriented design works.
bc4942,

If I am reading your post correctly:
  "I have an Access databas that does not allow objects like forms and tables to be modified in design mode."
And:
  "but I can find no way to get back to design mode without adding the default Access design mode button."

From this I can acertain that you have merely turned off/hidden the "View" button.
And/Or disabled the View menu commands

If so, then this is not a good way to protect your Objects because users can still use Ctrl+< and Ctrl+> to switch to design view.

The better way is to create an MDE file.
(Tools-->Database Utilities-->Make MDE file)
In an MDE file you don't have to worry about deleting the view button or menu commands because users will not be able to modify Forms or Reports by default.
But they can still create run, and yes, switch back and forth between datasheet view and design view before saving a query.

JeffCoachman
Avatar of bc4942

ASKER

I understand.  Unfortunately, I have not been able to get my database to make an MDE file in a few years.  Always get the following error:
"Microsoft Office was unable to create an MDE database."
This error is usually associated with compiling a large database into an MDE file.  Due to the method used to compile the database, a considerable number of TableID references are created for each table.  The Microsoft Jet database engine version 4.0 can only create a maximum of 2048 open TableIDs at one time.  Exporting a database as an MDE potentially can exceed this limit if the database has a large number of objects (table, macro, form, report, etc).
There is no accurate method to estimate the number of TableIDs the Jet database engine uses during the process of compiling a database as an MDE.  However, each VBA module and each form uses one TableID, as a result, if the database has 500 forms, and each form's HasModule property is set to Yes, as many as 1,000 TableIDs are used.
More information about this error message online.  
Are you able to COMPILE your database? Unless your database is HUGE (and I don't mean a couple dozen tables and forms) then you should be able to convert to MDE format. I've successfully compiled apps with 75 forms, 35+ reports, 75+ queries and somewhere around 35 tables. The most common issue when trying to convert to MDE is (a) trying to convert the wrong format (i.e. trying to convert an Access 2000 db while you're working in Access 2003) or (b) failing to compile the database before attempting to convert it.
Avatar of bc4942

ASKER

Yes, it is quites large.  There are no tables as it uses MySQL to store data, but there are lots of forms, reports, and queries with thousands of controls that will easily exceed the 2048 "table ID" limit of Access.
I can however compile the database and am running Access 2003 and the databas is in 2003 format.
bc4942,

The same thing happened to me a while ago.
Here is what I had to do:
Delete all unused Variables, Procedures, and Functions
Delete all excessive "White space"
Decopile the databse: (http://www.mvps.org/access/bugs/bugs0008.htm)

JeffCoachman