By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,930 Members | 1,321 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,930 IT Pros & Developers. It's quick & easy.

Closing a Form Dialogue After The Form That It Opens Is Done Processing

P: 2
Hi,
I have a button on the home form of my DB that opens a form dialogue asking the user to select a value from a combobox. After the value is selected and the user hits "OK" button on the dialogue, a macro is executed that opens a form with charts. The form with charts has a query as its data source. The query has the combobox from the dialogue form as the criteria for two of the fields.
Here's my problem...
Whenever the user hits "OK" on the dialogue, the macro first executes the Form with charts and then closes the dialogue box. Unfortunately, this means that the query that powers the Form with Charts doesn't have enough time to grab the combobox value from the dialogue. How can I fix this? I need the dialogue to stay open long enough for the charts to be generated and then close after the charts have finished rendering. I have tested using the macro that closes the Dialogue as an Event on the Form with Charts but none of the Events allow the Dialogue to stay open long enough for the charts to be generated.

Ideas??
Jul 1 '15 #1

✓ answered by jforbes

I agree with NeoPa, if you don't have to use Macros, then don't use them. Even though you seem to be so close to having this done, it would be tempting to just try to finish it, but you will be better off down the road if you spend the time to convert to VBA.

There is a second thing that you might want to address while you are at this. Having the Query for a Graph that refers to an Open Form as part of it's Critera isn't always the best approach. You run into things exactly like what you are experiencing. The Form isn't open when you need it.

You are better off setting things up so that the Form that is consuming the Query supplies the Criteria or creates the Query all together. There are a lot of ways to do this. A basic one for your situation would be to have the Form with the Chart on it be the one that is launched by your Home Form. The Chart Form would then launch the Dialog Form to get the criteria it needs, then the Chart Form would execute the Query with the provided Criteria to create the Chart. Setting it up this way, you can launch the Chart Form anyhow you want and it will have the means to get all the information it needs to display the Chart. The Timing issue goes away.

Share this Question
Share on Google+
3 Replies


NeoPa
Expert Mod 15k+
P: 31,769
It's a horrible approach as it uses macros which are just a whole bunch of problems waiting for you down the road, but if that's where you are then once you've opened the report in the macro you can close the triggering form.

My advice, should you wish or need to progress further with Access, is to get away from macros ASAP and into VBA code. It's more daunting to start with, but much less fraught in the long-run.

Best of luck.
Jul 2 '15 #2

jforbes
Expert 100+
P: 1,107
I agree with NeoPa, if you don't have to use Macros, then don't use them. Even though you seem to be so close to having this done, it would be tempting to just try to finish it, but you will be better off down the road if you spend the time to convert to VBA.

There is a second thing that you might want to address while you are at this. Having the Query for a Graph that refers to an Open Form as part of it's Critera isn't always the best approach. You run into things exactly like what you are experiencing. The Form isn't open when you need it.

You are better off setting things up so that the Form that is consuming the Query supplies the Criteria or creates the Query all together. There are a lot of ways to do this. A basic one for your situation would be to have the Form with the Chart on it be the one that is launched by your Home Form. The Chart Form would then launch the Dialog Form to get the criteria it needs, then the Chart Form would execute the Query with the provided Criteria to create the Chart. Setting it up this way, you can launch the Chart Form anyhow you want and it will have the means to get all the information it needs to display the Chart. The Timing issue goes away.
Jul 2 '15 #3

P: 2
Thanks! This is great info. I decided to get rid of the dialogue box all together and to simply place a combobox on the Form with the Charts. Now I just need to figure out the code for refreshing the charts when a combobox value is selected. Thanks for the help!
Jul 2 '15 #4

Post your reply

Sign in to post your reply or Sign up for a free account.