A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

How to get a query to call the parameter form



 
 
Thread Tools Display Modes
  #1  
Old March 7th, 2010, 09:15 PM posted to microsoft.public.access.queries
WillyNPG
external usenet poster
 
Posts: 2
Default How to get a query to call the parameter form

I am trying to use a form to get query parameter dates as is detailed in the
help article "Make a query ask for input" The query does not open the date
range form when the query is used If the form is opened in advance and dates
entered then the dates in the form are used what is missing? How is the open
form macro called ?
  #2  
Old March 7th, 2010, 09:46 PM posted to microsoft.public.access.queries
Marshall Barton
external usenet poster
 
Posts: 5,361
Default How to get a query to call the parameter form

WillyNPG wrote:

I am trying to use a form to get query parameter dates as is detailed in the
help article "Make a query ask for input" The query does not open the date
range form when the query is used If the form is opened in advance and dates
entered then the dates in the form are used what is missing? How is the open
form macro called ?



Well, there is probably some convoluted way to get a query
to open a form, but you can not guarantee that the form
would be opened and the values entered before the query
tried to use the values.

Instead you need to use some code to open the form before
the query runs. For example, if you want to use the query
as the record source for a report:
DoCmd.OpenForm "your form", WindowMode:=acDialog
DoCmd.OpenReport "your report", acviewPreview

--
Marsh
MVP [MS Access]
  #3  
Old March 7th, 2010, 09:57 PM posted to microsoft.public.access.queries
John W. Vinson
external usenet poster
 
Posts: 18,261
Default How to get a query to call the parameter form

On Sun, 7 Mar 2010 13:15:01 -0800, WillyNPG
wrote:

I am trying to use a form to get query parameter dates as is detailed in the
help article "Make a query ask for input" The query does not open the date
range form when the query is used If the form is opened in advance and dates
entered then the dates in the form are used what is missing? How is the open
form macro called ?


You've got it backward.

Queries don't have events that would let you open a form; it's vice versa.
Open the form first, and open the query (or, much better, the report or form
based on the query) from some event on the form - a command button or the
AfterUpdate event of some appropriate control on the form.
--

John W. Vinson [MVP]
  #4  
Old March 8th, 2010, 12:49 AM posted to microsoft.public.access.queries
KenSheridan via AccessMonster.com
external usenet poster
 
Posts: 1,610
Default How to get a query to call the parameter form

My recent response in the following thread includes a description of one way
(there are others) to get a report to open a dialogue form for entering
parameters for the report's underlying query:

http://www.accessmonster.com/Uwe/For...ing-parameters


Something similar could be done with a form based on the query.

While people sometimes prefer to do it this way, the only situation in which
I can see it has any advantage is if the same dialogue form is used for
multiple reports or forms, in which case a small variation to the code
involves passing the report name to the form as its OpenArgs property. If
the dialogue simply feeds one report or form just opening the dialogue form
first and then opening the report or bound form (or even a query in datasheet
view, though that's a rather crude approach in a developed application) from
it has always seemed to me to be a perfectly adequate way of going about it.

Ken Sheridan
Stafford, England

WillyNPG wrote:
I am trying to use a form to get query parameter dates as is detailed in the
help article "Make a query ask for input" The query does not open the date
range form when the query is used If the form is opened in advance and dates
entered then the dates in the form are used what is missing? How is the open
form macro called ?


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...eries/201003/1

  #5  
Old March 8th, 2010, 12:52 AM posted to microsoft.public.access.queries
Steve Schapel
external usenet poster
 
Posts: 1,422
Default How to get a query to call the parameter form

Willy,

As I stated in the other group where you posted this...

The behaviour you have described is expected. The form will not, and can
not be made to, open when the query is run. If the query uses criteria
based on the values of controls on a form, then the form has to be open in
advance.

As for the macros, it sounds like you are using Access 2007 and they are
embedded macros. That is fine... but they won't appear in the Navigation
Pane.

--
Steve Schapel, Microsoft Access MVP


"WillyNPG" wrote in message
...
I am trying to use a form to get query parameter dates as is detailed in
the
help article "Make a query ask for input" The query does not open the date
range form when the query is used If the form is opened in advance and
dates
entered then the dates in the form are used what is missing? How is the
open
form macro called ?


  #6  
Old March 9th, 2010, 04:28 PM posted to microsoft.public.access.queries
WillyNPG
external usenet poster
 
Posts: 2
Default How to get a query to call the parameter form

I believe you are correct Steve. The puzzle is why does the help screen
article include a macro to open the form using the Not IsLoaded("Date Range")
in the condition if there is no way to make the form open before the query
is run. Perhapse it can only work in an application written in VB

"Steve Schapel" wrote:

Willy,

As I stated in the other group where you posted this...

The behaviour you have described is expected. The form will not, and can
not be made to, open when the query is run. If the query uses criteria
based on the values of controls on a form, then the form has to be open in
advance.

As for the macros, it sounds like you are using Access 2007 and they are
embedded macros. That is fine... but they won't appear in the Navigation
Pane.

--
Steve Schapel, Microsoft Access MVP


"WillyNPG" wrote in message
...
I am trying to use a form to get query parameter dates as is detailed in
the
help article "Make a query ask for input" The query does not open the date
range form when the query is used If the form is opened in advance and
dates
entered then the dates in the form are used what is missing? How is the
open
form macro called ?


.

  #7  
Old March 9th, 2010, 05:42 PM posted to microsoft.public.access.queries
KenSheridan via AccessMonster.com
external usenet poster
 
Posts: 1,610
Default How to get a query to call the parameter form

I haven't seen the Help topic in question, but using a macro, one approach
would be to run the following actions in the macro:

1. OpenForm: open the form for entering the parameter in Dialog mode. When
a form is opened in dialogue mode the execution of the macro will pause until
the form is closed or hidden.

2. OpenQuery: open the query which references the form.

In the dialogue form hide it by putting the following line of code in
whatever event is used to confirm the parameter entered. This could be the
AfterUpdate event procedure of the control in which the parameter is entered
(if only one parameter) or the Click event procedure of a separate button (if
more than one parameter, e.g. the start and end of a date range, is entered)

Me.Visible = False

However, this still requires the macro to be run to open the query. There is
no way opening a query directly will trigger a macro or will automatically
open the dialogue form in any other way. While the above will work I don't
see that it has any advantage over simply opening the form, and then opening
the query ( or preferably a form or report based on it) from the form.

Ken Sheridan
Stafford, England

WillyNPG wrote:
I believe you are correct Steve. The puzzle is why does the help screen
article include a macro to open the form using the Not IsLoaded("Date Range")
in the condition if there is no way to make the form open before the query
is run. Perhapse it can only work in an application written in VB

Willy,

[quoted text clipped - 19 lines]

.


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...eries/201003/1

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 01:30 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.