472,365 Members | 1,277 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,365 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 12997
-----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: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.

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.