Solved

How to programmatically switch query to design mode

Posted on 2008-10-01
12
821 Views
Last Modified: 2013-11-29
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!
0
Comment
Question by:bc4942
  • 4
  • 4
  • 2
12 Comments
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 125 total points
ID: 22619222
docmd.OpenQuery "YourQuery",acViewDesign
0
 

Author Comment

by:bc4942
ID: 22634856
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.
0
 
LVL 84
ID: 22635065
You couldn't ... you'd have to save the query, then open it in Design view.
0
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 

Author Comment

by:bc4942
ID: 22636829
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.
0
 
LVL 84
ID: 22637496
I would suppose it builds a temporary query and allows you to work with that. That's typically the way object-oriented design works.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 22643541
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
0
 

Author Comment

by:bc4942
ID: 22650373
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.  
0
 
LVL 84
ID: 22650793
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.
0
 

Author Comment

by:bc4942
ID: 22669084
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.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 22674790
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
0

Featured Post

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

827 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