Getting a Custopm Dialog Box to work!

wjoc1

Registered User.
Local time
Today, 23:48
Joined
Jul 25, 2002
Messages
117
Hi I have a form based on an underlying query and this query prompts for 2 pieces of information before the form opens.

I have created a custom dialog box which I want to use instead of one of the default dialog boxes the query pops up. I have tried placing a reference to the form in the criteria cell of the required field in the query but it doesn't seem to work.

The reference is right, I'm sure of that. For example it might be:

Forms![some_form]![some control]

When I now try and open the form the query runs as usual and I still get a default prompt with "Forms![some_form]![some_control]" as the text.

What am I doing wrong and also what code do I put in the ok button to pass the information back to the query?

Thanks,

Liam
 
A few basic suggestions

As you have stated the query is not picking up the value of the control, therefore I believe that the reference to the form must be wrong. check that the form is open when the query is run(probably so if the button that runs the query is on the same form as the criteria.)

When this happens, I usually leave the form open, open the query in design view and right click in the criteria and use the 'build' option to find the field under the Forms-LoadedForms
tree and select the control from second column of the expression builder, that way you are guaranteed that the field reference is correct.

Besides that I can only think that you should test the referencing of the query by making reference to another control as a test.
 
Just out of curiousity... Do you have your code setup to close the dialog box before opening the form?

The first time I setup a dialog box this challenge stumped me a long time.
 
Thanks for the help. As it turns out it was just stupid me all along(no surprises there!) I was running the query BEFORE inputting the data in the dialog box. I stupidly thought that when I ran the query the dialog box would pop up. Not so as it turns out...

Incidentally how do I close that dialog box. If I use the DoCmd.Close after the DoCmd.OpenForm the form never opens???

Thanks again,

Liam
 
If you open a form first and then want to close the form you're one you have to reference the form in your close line:

docmd.close acform, "Formname"

Otherwise it will just close what it just opened.
 

Users who are viewing this thread

Back
Top Bottom