473,386 Members | 1,743 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Call query design view from code

NB
Hi

Is there any way to call up the query design view from code?

In my compiled-as-MDE app everything is hidden from end users.
However, I want advanced user to have access to the query design view
so they can create, run and export their own query.

Another question is: can they be prevented from saving those
on-the-fly queries?

Thks
NB
Nov 12 '05 #1
6 13243
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I'm not sure, but I believe you have to do it in a round-about way:

In VBA:

1. Create a named QueryDef
- CurrentDb.CreateQueryDef()
2. Open that query in design view
- docmd.OpenQuery "qry name",acViewDesign
2a. Use a timer event to watch for the query to be closed
- use the Northwind IsLoaded() function
3. Hope the user doesn't save the query under another name ;-)
4. Delete the just-created query
- docmd.DeleteObject acQuery, "qry name"

Sorta kludgey, but it may work.

Otherwise - give the users (each of them) a .mdb file that is linked
to the data tables & allow them to create all the junk they want.

MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBP+JxW4echKqOuFEgEQLaHgCfazAeQpeSFhxJ6Iy4hSXrOh uDo2AAnjmW
nD0i3xdmzxypF9xeY3aLXETJ
=JCg1
-----END PGP SIGNATURE-----

NB wrote:
Hi

Is there any way to call up the query design view from code?

In my compiled-as-MDE app everything is hidden from end users.
However, I want advanced user to have access to the query design view
so they can create, run and export their own query.

Another question is: can they be prevented from saving those
on-the-fly queries?

Thks
NB


Nov 12 '05 #2
NB
My solution so far has been

Create a temp query and open it in design view
The code below did that (where QExist is a function to check if
tempQuery exists)

Dim qdf As QueryDef
If QExist("tempQuery") Then
CurrentDb.QueryDefs.Delete ("tempQuery")
Set qdf = DBEngine(0)(0).CreateQueryDef("Tempquery", "select
version from tblversion")
qdf.Close
DoCmd.OpenQuery "Tempquery", acViewDesign
Else
Set qdf = DBEngine(0)(0).CreateQueryDef("Tempquery", "select
version from tblversion")
qdf.Close
DoCmd.OpenQuery "Tempquery", acViewDesign
End If

The problem is
- I can set focus to the design view that is opened (When the above
code is run from a command button in a form, screen flickers and then
focus returns to the calling form. The opened query design view stays
behind)
- I can't open a blank design grid. Opening the grid with a table does
not look very nice.

Anyone can give some hints?

Thks
NB
Nov 12 '05 #3
try something like

Public Function MyFunction()

Dim qdf As QueryDef
' CurrentDb.QueryDefs.Delete ("tempQuery")
' Set qdf = DBEngine(0)(0).CreateQueryDef("Tempquery", "select version
from tblversion")
' qdf.Close
' DoCmd.OpenQuery "Tempquery", acViewDesign
' Else
Set qdf = CurrentDb().CreateQueryDef("Tempquery", "select RevisionNumber
from tblVersion")
qdf.Close
DoCmd.OpenQuery "Tempquery", acViewDesign

End Function

this puts up a design grid.
the only significant change I made was to change "DBEngine(0)(0)." for
"CurrentDB()." ( and comment out some lines about deleting it if it
already exists ( I don't have your function: QExist("tempQuery") to call )
You may also want to look at the repaintobject command

John Bickmore
www.BicycleCam.com
www.Feed-Zone.com

"NB" <ni******@lycos.com> wrote in message
news:5c**************************@posting.google.c om...
My solution so far has been

Create a temp query and open it in design view
The code below did that (where QExist is a function to check if
tempQuery exists)

Dim qdf As QueryDef
If QExist("tempQuery") Then
CurrentDb.QueryDefs.Delete ("tempQuery")
Set qdf = DBEngine(0)(0).CreateQueryDef("Tempquery", "select
version from tblversion")
qdf.Close
DoCmd.OpenQuery "Tempquery", acViewDesign
Else
Set qdf = DBEngine(0)(0).CreateQueryDef("Tempquery", "select
version from tblversion")
qdf.Close
DoCmd.OpenQuery "Tempquery", acViewDesign
End If

The problem is
- I can set focus to the design view that is opened (When the above
code is run from a command button in a form, screen flickers and then
focus returns to the calling form. The opened query design view stays
behind)
- I can't open a blank design grid. Opening the grid with a table does
not look very nice.

Anyone can give some hints?

Thks
NB

Nov 12 '05 #4
do you have some code in the form that puts the point of execution back into
the form after creating the query, firing the OnActivate and GotFocus
events? is there any offending code in those events?

John Bickmore
www.BicycleCam.com
www.Feed-Zone.com

"NB" <ni******@lycos.com> wrote in message
news:5c**************************@posting.google.c om...
My solution so far has been

Create a temp query and open it in design view
The code below did that (where QExist is a function to check if
tempQuery exists)

Dim qdf As QueryDef
If QExist("tempQuery") Then
CurrentDb.QueryDefs.Delete ("tempQuery")
Set qdf = DBEngine(0)(0).CreateQueryDef("Tempquery", "select
version from tblversion")
qdf.Close
DoCmd.OpenQuery "Tempquery", acViewDesign
Else
Set qdf = DBEngine(0)(0).CreateQueryDef("Tempquery", "select
version from tblversion")
qdf.Close
DoCmd.OpenQuery "Tempquery", acViewDesign
End If

The problem is
- I can set focus to the design view that is opened (When the above
code is run from a command button in a form, screen flickers and then
focus returns to the calling form. The opened query design view stays
behind)
- I can't open a blank design grid. Opening the grid with a table does
not look very nice.

Anyone can give some hints?

Thks
NB

Nov 12 '05 #5
NB
xzzy: What is the difference between the piece of code that you posted
and mine? I think with your code the query grid still shows up with a
table in it, and that's what I want to improve on (to make the look
cleaner)

I put my code in the Onclick event of a label on a menu screen
(frmMain)

To give the menu a consistent look (pointing hand) when user hovers
the mouse over items, I hyperlink that label to the form frmMain
itself. And I guess that's the problem: the Onclick event fires first,
then the app follows the hyperlink back to frmMain.

I couldn't think of a solution yet. Using api call to change cursor
icon is unecessarily awkward since I want my menu system to be real
light weight ...
NB
Nov 12 '05 #6
> xzzy: What is the difference between the piece of code that you posted
and mine? I think with your code the query grid still shows up with a
table in it, and that's what I want to improve on (to make the look
cleaner)
I misread your question, sorry
I put my code in the Onclick event of a label on a menu screen
(frmMain)

To give the menu a consistent look (pointing hand) when user hovers
the mouse over items, I hyperlink that label to the form frmMain
itself. And I guess that's the problem: the Onclick event fires first,
then the app follows the hyperlink back to frmMain.
look into "RepaintObject". This may help, it's a snip of code I use to get
a form or report to return to the previous menu. the following is from Case
Else of that function

DoCmd.OpenForm "frmMenuMain"
DoCmd.SelectObject acForm, "frmMenuMain", 0
DoCmd.RepaintObject acForm, "frmMenuMain"

John Bickmore
www.BicycleCam.com
www.Feed-Zone.com

"NB" <ni******@lycos.com> wrote in message
news:5c**************************@posting.google.c om... xzzy: What is the difference between the piece of code that you posted
and mine? I think with your code the query grid still shows up with a
table in it, and that's what I want to improve on (to make the look
cleaner)

I put my code in the Onclick event of a label on a menu screen
(frmMain)

To give the menu a consistent look (pointing hand) when user hovers
the mouse over items, I hyperlink that label to the form frmMain
itself. And I guess that's the problem: the Onclick event fires first,
then the app follows the hyperlink back to frmMain.

I couldn't think of a solution yet. Using api call to change cursor
icon is unecessarily awkward since I want my menu system to be real
light weight ...
NB

Nov 12 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Ryan | last post by:
I came across a situation that I've been unable to explain and was hoping somebody had an answer: I had written an update query which was taking about 8 seconds to run and considered it too...
3
by: Megan | last post by:
hi everybody- it seems like my update query should work. the sql view seems logical. but that might be up to discussion...lol...i'm a newbie! UPDATE , Issue SET .IssueID = . WHERE ((.=.));
6
by: jjturon | last post by:
Can anyone help me?? I am trying to pass a Select Query variable to a table using Dlookup and return the value to same select query but to another field. Ex. SalesManID ...
6
by: sghi | last post by:
Hi All, I'm new to this group and quite new to access/vba. So, shortly after beginning to write a simple application for my wife, I came across a blocking problem: I need to intercept the sql...
7
by: John Øllgård Jensen | last post by:
Hi Using MS Asccess 2000: In a query I'm trying to create a new field with following expression: FilmDate: Left(,4) The field "FilmNo" is another text field in the query. This is...
4
by: amy | last post by:
Hi to Everyone: I need big help on how to query the Age range. Age field is text data type, Age are from 0 wk, 1 wk, 2wk.....up to 15 wk. Try to set up query in Query desing mode with criteria is...
22
by: Stan | last post by:
I am working with Access 2003 on a computer running XP. I am new at using Access. I have a Db with a date field stored as mm/dd/yyyy. I need a Query that will prompt for the month, ie. 6 for...
3
by: mnjkahn via AccessMonster.com | last post by:
I'm running Access 2003, modifying a query that has over 45 fields. When I right click on the field name in Query Design View, and then click Build, Access crashes before the Build window...
2
by: existential.philosophy | last post by:
This is a new problem for me: I have some queries that open very slowly in design view. My benchmark query takes about 20 minutes to open in design view. That same query takes about 20 minutes...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.