How to close form and cancel query?

torok

Registered User.
Local time
Today, 12:13
Joined
Feb 3, 2002
Messages
68
Please help me get rid of unwanted messages. Here is a detailed explanation of the problem:

The Problem:

I have a report based on a query.
When I click on the the switchboard item to open the report, the report runs a macro in its "on open" event.

The macro opens a "date" form that allows the user to enter two date parameters that restrict the query results to show records between those two dates only.

Pressing "OK" on the form works great.

Pressing "Cancel" runs a macro that closes the "date" form, but then another window pops up asking for the parameter as specified in the query. (i.e. Forms!frm_dates!BeginDate) I have to press that window's "cancel" button as well.

The Question:
How can I stop that box from popping up when the user presses "Cancel" on the "date" form?

Thanks!
 
That's a good question I have battled with this problem for months on end and I have still not come up with a solution. If you find out please let me know, Likewise If I do manage to get round this I shall be in touch.

Hay
 
Macro Setup

I have virtually the same setup. In my macro, I have 3 names: Preview, Print and Cancel. In the actions for the cancel button, I have "Close" (closes the form that has the cancel button on it). In your on_click event for your cancel button you need to put nameofyourmacro.Cancel (If cancel is what you named that part of the macro) i.e. if you had 3 names (Preview, Print, Close) and three actions in your macro you would put nameofyourmacro.Close in the on_click event of your Cancel button.

Is this too confusing? Let me know if it is and i'll elaborate. :)
 
In my macro I have open form, close form, ok and cancel.

In the reports on open event: I have ContractDialoug.Open Dialoug

On close event: ContractDialoug.Close Dialoug

Ok cmdbutton which is on a pop up form: ContractDialoug.OK
Cancel Cmdbutton ContractDialoug.Cancel

Now all of the above works with the exception of the cancel button which insists on bringing up a second parameter when the cancel cmdbutton is clicked.

I just do not have the answer for this!!

Hay

ps All spellings are correct
 
Yes, my setup is already as Audrey suggested, but to no avail. This may be unsolvable, but if I find a solution I'll post it :(

Very disappointing.
 
OK, let me suggest this.

Your parameter form: select_date_form
Report that opens that is based on the query: info_report
Query that your report is based on: select_date_query
Macro Name: select_date_macro

In your select_date_query set your criteria for the dates you want to =[forms]![select_date_form]![name_of_your_textbox]

OR set it to =between [forms]![select_date_form]![textbox1] AND [forms]![select_date_form]![textbox2] (whatever suits you)

In your macro:
Macro Name: Open dialog Actions: Open Form Action arguments: form Select_date_form
Macro Name: Close Actions: Close form select_date_form
Macro Name: OK Actions: setvalue Action arguments: item:[visible] expression: no
also another action under the .OK macro: OpenReport Action arguments : info_report
Macro Name: cancel actions: close action arguments form: select_date_form

Now, the only thing you need (regarding this) on your report is it's record source set to the select_date_query. There is no need to have on_open or on_close arguments.

In your select_date_form Ok button: on_click: select_date_macro.OK
On the Cancel button on_click: select_date_macro.Cancel

That should do the trick
 
Hi Audrey still not sure about this one, basically what I have is as follows:

MyQuery: QryCategoryDialoug, qry criteria is set to [Forms]![FrmCategoryDialoug]![CategoryID] (this is looking to the combobox on my pop up form)

My pop up forms opens upon opening the report (the reports on open event which comes from the macro CategoryDialoug.open. This then allows the user to make their selection from the combo then the Ok cmdbutton hides the form thus showing the selected results in the report. This all works fine no problems. The cancel button should close the form in which it does BUT it still gives me a parameter after closing it If I select cancel again here it all ok.

It's really very annoying and I appreciate your help

Thanks again
Hay

ps I know I am referring to CategoryDialoug here and not ContractDialoug as in my above post..I have quite a few of them!
 
ok, it looks like what you need to do here is on your "Cancel" macro you need to have it Close your report and the form. Try adding another action to the Cancel macro that says to close the report along with closing the form.

What's going on here is when you open your report it's looking for the data in your query. But before your query can obtain its data, first data has to be entered in your form. So if you try to open the report without there being any data in your form, your report asks for those parameters before it can open. Thus when you hit "Cancel" on your form it might close your form, but your report still needs the data.

However, if you need to be able to open the form without entering parameters you might want to think about adding an option group that allows you to select either 'Select Category ID" or "Open the Report without a Selection".

I also want to ask you if you get the "parameter request error message" as soon as you try to open the report/form or if you get it only when you hit the cancel button?
 
Hi Audrey

Thanks for the time you are giving me on this one. That makes sense what you are saying. It's not even an error message I get just a parameter like you would see if you entered this in a query. It just comes up forms!controlname! etc etc and I only get this when I select the cancel button not when I open the report.

Hay
 
Just so you'll know... the way i have mine setup is : the user clicks a button on the switchboard that says "View Report" that 'View Report" button opens my parameter form, then on the ok button of that parameter form, my macor opens the report. That way the report has its parameters before it is ever opened. But you might not have a switchboard and you just want to be able to open the report then enter the parameters. try putting the "Close report" also on the Cancel macro. If that doesn't work, let me know and I'll create the same circumstances and let you know how i solved it. Good luck!
 
I tried as you suggested but now if I select cancel I get this error message "A macro specified as the on open, on close, on format, on retreat, onpage or onprint property setting contains an invalid action for the property"

I don't have this setup from my switchboard. I have a custom toolbar where the user will select their report.

I looked at the help files on this and they describe to do this the way I have it setup (I must have missed something along the way) The only thing I don't have that the help mentions on this topic is the ISloaded function to check whether the form is open Is this perhaps what is causing my problem? Audrey can you enlighten me on this or perhaps anyone else?

Thank you you really are patient!

Hay
 
well, lol, doesn't it just get fun sometimes. You can email it to me if you want and i'll see what i can do. I'll email it back to you along with directions on what i did. audrey@flaservices.com
 
For future reference the IsLoaded function was the missing link. Audrey very kindly sorted this for me, thanks very much Audrey.

Torok maybe this is what you're missing also?

Very happy now..cheers!!!

Hay
 
For future reference the IsLoaded function was the missing link. Audrey very kindly sorted this for me, thanks very much Audrey.

Torok maybe this is what you're missing also?

Very happy now..cheers!!!

Hay

Hi,

I know this is ancient history to you now, but I'm having exactly this problem i.e. I have in the open event for report "rptByUser" the form "frmByUser" which asks for search dates for the report, put them in and the report gives results between the dates "txtDateFrom" and "txtDateTo". However, should a user change their mind, they can cancel the form without an error, but the "qryByUser" seems to still run, as the small parameter window comes up 'Enter Parameter Value' with the field waiting for entry "Forms!frmByUser!txtStartDate" (which is specified in the query Criteria field.) Can either of you remember what the upshot of the original question was - how did you implement the IsLoaded function? Sorry to do it this way, but I'm finding it pretty difficult to find a solution for this!
 

Users who are viewing this thread

Back
Top Bottom