Query-Based Report - How do I suppress display of Query result

blackduck603

Registered User.
Local time
Today, 01:49
Joined
Dec 27, 2007
Messages
16
In Access 2000, I have created a report that uses a Query as the RecordSource.

rptMyReport
RecordSource: qryInventoryDetailsDivisionParam


The Query requires one parameter which it gets from a form.

SELECT [InventoryItems].[InvCtrlNum], [InventoryItems].[ItemDesc], [InventoryItems].[PurchaseDate], [InventoryItems].[PurchasePrice], [PO], [SN], [InventoryItems].[StatusDesc], [LocationName], [DivisionName]
FROM InventoryItems
WHERE [InventoryItems].[DivisionName]=[Forms]![GetDivisionParamForm]![DivisionCombo];


I'v got everything tied together so that when I launch the report, the form gets launched to prompt for the required parameter and then the query executes. The report gets displayed with the correct data
BUT
the query results are also displayed.

I just tried adding code to Close the query, but it sure isn't graceful. The user can see the Query results open and then close before the report is displayed.

Here is my Form's code:
-------------------------------------------------------------------------
Option Compare Database

Private Sub Cancel_Click()
DoCmd.Close 'Close Form
End Sub

Private Sub OK_Click()

Me.Visible = False
DoCmd.OpenQuery "qryInventoryDetailsDivisionParam", acViewNormal, acEdit

'***************************************************
' This closes the Query output, but it ain't pretty
DoCmd.Close acQuery, "qryInventoryDetailsDivisionParam"
'***************************************************


End Sub

Private Sub Form_Open(Cancel As Integer)
If Not bInReportOpenEvent Then
' If we're not called from the report
MsgBox "For use from the Inventory Detail Rpt for Specific Division only", _
vbOKOnly
Cancel = True
End If
Form_Open_Exit:
Exit Sub
End Sub
-------------------------------------------------------------------------

Does anyone know if there is a way to entirely suppress the query?

Seems like there should be a way to do this.......If I have a Query-Based report that requires no parameters, the report gets displayed without the query results popping up. I guess the part that is throwing me is when I have to use a Form to get a parameter for a query behind a report.


I appreciate any comments, suggestions, etc.
 
If the report has the query as its recordsource, there is no reason to launch the query separately.
 
OK - I gotcha.

I commented out the following line in my form's OK click event handler.

DoCmd.OpenQuery "qryInventoryDetailsDivisionParam", acViewNormal, acEdit

For some reason, I was thinking that this is what got the query to execute to populate my report. I forgot that the RecordSource itself takes care of this.
My Bad....


Thanks !!!
 

Users who are viewing this thread

Back
Top Bottom