Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Report using criteria from a Form Problem

Status
Not open for further replies.

calihiker

Technical User
Jun 13, 2003
96
US
Is there a way to program a report (a report using parameters from a form) to close and not prompt for the missing parameter values if the form is closed (by the user, if the user wants to exit out -for example user pressing the exit button)??

Thanks in advance!!
 
Are you referring to a button that would close the form? If so, just make the form invisible. Also, some users are trainable. I don't remember this ever being a problem with any users in about 10 years of contract programming with Access.

Duane
MS Access MVP
 
Well, the problem is that if a user cancels out of the form - the report still asks for the parameter values that are to be taken from the form... I would like to know if there is some way to supress the prompting of those parameters and just close the report, if the user clicks on the cancel button -but i can't figure out how.

Here's my code from the cancel button...

Public Sub cmdCancel_Click()
DoCmd.Close acReport, "Report_2002GiftsAllDrops_CircPlan_SubReport(Buyers)"
DoCmd.Close acForm, "frmParameters", acSaveNo
End Sub

Any ideas??

Thanks in advance!!
 
I added some code to explicitely close the report if user presses the cancel button and thereby closes the form. And I still get prompted to enter in values for the parameter, which I don't want to do if I want to cancel out and close everything...

Here's my code ..

Private Sub Report_Open(Cancel As Integer)
Dim fcount As Integer

DoCmd.OpenForm "frmParameters", acNormal, , , acFormEdit, acDialog 'this suspends running of report until form is hidden or closed
'code pause here until a buttom is pushed...

fcount = IIf(Forms.Count = 0, 0, 1) 'counts how many forms are open and flags variable if at least one is open

If fcount = 0 Then 'runs if no forms are open, suppose to close the report if the parameter form is closed
DoCmd.Close acReport, "Report_2002GiftsAllDrops_CircPlan_SubReport(Buyers)"
End If
'problem is it still asks for parameters

End Sub

Any help would be very appreciated, I've been stuck on this problem for awhile!!

Thanks :)
 
If your users are clicking the close [X] then set your form to not display it. Your close button on the form can set the visible property of the form to False.
Once a report has begun to open, I believe it will prompt for any criteria parameters.

An alternative me be to set global variables with the criteria values. Then create a function to retrieve the values. Your function might be something like:
Function GetStartDateCrit() as Date
GetStartDateCrit = gdatStartDate
End Function
Then your criteria would be:
>=GetStartDateCrit()

Duane
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top