Interactive queries

  • Thread starter Thread starter SecretCharacter
  • Start date Start date
S

SecretCharacter

Hi all,
Is it possible to create a query that takes arguements from a form to do
filtering? And can I do a display of the results on a report immediately. I
wish to create a search form where I pass in the arguements in a form and
the results will come out on a report. Thanks a zillion in advance.
 
SecretCharacter said:
Hi all,
Is it possible to create a query that takes arguements from a form to do
filtering? And can I do a display of the results on a report immediately. I
wish to create a search form where I pass in the arguements in a form and
the results will come out on a report. Thanks a zillion in advance.

The criteria of a query can be an entry like...

Forms!FormName!ControlName

If you want to do more than a handful of controls though it is better to use
code that basically writes the query's SQL statement in code. For a handful of
criteria controls though the form reference syntax works well.
 
Here's an outline of how to set it up ---
(Use Rick's response for the query)

Put the following code in the Open event of the report:
On Error Resume Next
DoCmd.Open "NameOfSearchForm",,,,,acDialog
If Not IsLoaded("NameOfSearchForm") Then
Exit Sub
End If
DoCmd.Close acForm, "NameOfSearchForm"

You can find the IsLoaded function in Northwind standard modules!

For your search form, include two buttons:
View Report
Cancel
Put the following code in the View Report button's Click event:
Me.Visible = False
Put the following code in the Cancel button's Click event:
DoCmd.Close
 
Back
Top