Kamis, 08 September 2011

[MS_AccessPros] Closing report from parameters form

 

Hi there-

I have a basic report and a parameters form. So that the users can filter, sort and group on the fly, I have it so that on the report's open event the parameters form is opened in dialog mode. The user then chooses their filters, clicks okay, and then the form hides and the report continues its open event using the appropriate filters and sorting.

My question is if the user decides to cancel the report formation by clicking cancel on the parameters form, how do I properly cancel the report's open event?

In case I'm not explaining myself well, here's the basic code:

Private Sub Report_Open(Cancel As Integer)
On Error GoTo Err_Report_Open

DoCmd.OpenForm "Params_AdminStatusRptsl", , , , , acDialog

Dim mysql As String
mysql = ......

Me.RecordSource = mysql & " where " & Forms![Params_AdminStatusRpts].[txtWhereClause]

...................................................................

This is the okay button on the form.....
Private Sub cmdOK_Click()
On Error GoTo Err_cmdOK_Click

'call the procedure to build the where clause
BuildWhereClause

'Now that the where clause is in a text box on the form, make the form invisible so that the report can continue to open
Me.Visible = False
....................................................................

This is the cancel button on the form....
Private Sub cmdCancel_Click()
On Error GoTo Err_cmdCancel_Click

DoCmd.close

Thanks in advance for your help!
Elizabeth

__._,_.___
Recent Activity:
MARKETPLACE
A bad score is 579. A good idea is checking yours at freecreditscore.com.

Stay on top of your group activity without leaving the page you're on - Get the Yahoo! Toolbar now.

.

__,_._,___

Tidak ada komentar:

Posting Komentar