Create a custom dialog box to use with a parameter query

  • Thread starter Thread starter Suzanne Wyatt
  • Start date Start date
S

Suzanne Wyatt

Hello again all.
I want to create a custom dialog box that pops up for selection of an
option from an option group as the criteria for a parameter query, that
prints a report.
How do I get this to work?
I have a small form with an Option Group with 4 options, I have it set as
dialog and as a pop-up, and I have set the criteria cell in my query to the
form, but it does not pop up, when I try to run the query. What have I done
wrong? Should I set the on open even of the report to the pop up form for
the query?
 
Your query will not cause a form to run. What you do is open the form, make
the selection, and then run the query (usually by clicking a command button
on the form); have the query use the value of the option group on the form
as its criterion value:
[Forms]![PopUpForm]![OptionGroupName]

Remember to somehow close the popup form after you've read the value of the
option group. Usually, the code would make the popup form invisible, run the
query, and then close the popup form.
 
Could I do this on the option group as an on click event?
And also should I run the query or run the report it's connected to? As I
want the criteria selected for the report and not just the query.
So would the syntax for the code be:
doCmd.openreport "Client Call List"
pfrmInterval.Invisible



Ken Snell said:
Your query will not cause a form to run. What you do is open the form, make
the selection, and then run the query (usually by clicking a command button
on the form); have the query use the value of the option group on the form
as its criterion value:
[Forms]![PopUpForm]![OptionGroupName]

Remember to somehow close the popup form after you've read the value of the
option group. Usually, the code would make the popup form invisible, run the
query, and then close the popup form.

--
Ken Snell
<MS ACCESS MVP>

Suzanne Wyatt said:
Hello again all.
I want to create a custom dialog box that pops up for selection of an
option from an option group as the criteria for a parameter query, that
prints a report.
How do I get this to work?
I have a small form with an Option Group with 4 options, I have it set as
dialog and as a pop-up, and I have set the criteria cell in my query to the
form, but it does not pop up, when I try to run the query. What have I done
wrong? Should I set the on open even of the report to the pop up form for
the query?
 
You can use an option group as the source of the value that the query uses
as its criterion. I wouldn't use the click event of the option group to run
the report, though, because I like to let the user be sure that he/she has
selected the correct option...hence, I use a command button to run the
report.

In your case, you would not run the query...instead, you'd open the report
that is based on the query. Opening the report will cause the query to run.

--
Ken Snell
<MS ACCESS MVP>

Suzanne Wyatt said:
Could I do this on the option group as an on click event?
And also should I run the query or run the report it's connected to? As I
want the criteria selected for the report and not just the query.
So would the syntax for the code be:
doCmd.openreport "Client Call List"
pfrmInterval.Invisible



Ken Snell said:
Your query will not cause a form to run. What you do is open the form, make
the selection, and then run the query (usually by clicking a command button
on the form); have the query use the value of the option group on the form
as its criterion value:
[Forms]![PopUpForm]![OptionGroupName]

Remember to somehow close the popup form after you've read the value of the
option group. Usually, the code would make the popup form invisible, run the
query, and then close the popup form.

--
Ken Snell
<MS ACCESS MVP>

Suzanne Wyatt said:
Hello again all.
I want to create a custom dialog box that pops up for selection of an
option from an option group as the criteria for a parameter query, that
prints a report.
How do I get this to work?
I have a small form with an Option Group with 4 options, I have it
set
as
dialog and as a pop-up, and I have set the criteria cell in my query
to
the
form, but it does not pop up, when I try to run the query. What have
I
done
wrong? Should I set the on open even of the report to the pop up form for
the query?
 
So, If I create a cmdbutton on my pop-up form that runs a report that the
underlying query is linked to it will filter the results.
What I have is a dialog form that I pop up before the report to select one
of 4 options to filter the criteria,
I placed a command button on the form to run the report after an option is
selected. I used the wizard to add the command button. and This is the code
I have in the on click event.
Private Sub cmdInterval_Click()
On Error GoTo Err_cmdInterval_Click

Dim stDocName As String

stDocName = "Clients to Call"
DoCmd.OpenReport stDocName, acPreview

Exit_cmdInterval_Click:
Exit Sub

Err_cmdInterval_Click:
MsgBox Err.Description
Resume Exit_cmdInterval_Click

End Sub
What else should I have to close the form?
Ken Snell said:
Your query will not cause a form to run. What you do is open the form, make
the selection, and then run the query (usually by clicking a command button
on the form); have the query use the value of the option group on the form
as its criterion value:
[Forms]![PopUpForm]![OptionGroupName]

Remember to somehow close the popup form after you've read the value of the
option group. Usually, the code would make the popup form invisible, run the
query, and then close the popup form.

--
Ken Snell
<MS ACCESS MVP>

Suzanne Wyatt said:
Hello again all.
I want to create a custom dialog box that pops up for selection of an
option from an option group as the criteria for a parameter query, that
prints a report.
How do I get this to work?
I have a small form with an Option Group with 4 options, I have it set as
dialog and as a pop-up, and I have set the criteria cell in my query to the
form, but it does not pop up, when I try to run the query. What have I done
wrong? Should I set the on open even of the report to the pop up form for
the query?
 
Back
Top