Jumat, 09 September 2011

[MS_AccessPros] Re: Closing report from parameters form

 

Thanks Lee and Graham for all your help!!!

--- In MS_Access_Professionals@yahoogroups.com, "Lee" <leevt99@...> wrote:
>
> Ok, it's the end of the day... if you don't hide the form, then nothing happens. Bleh.
>
> I just set up a mini test environment where a report opened a form in dialog and waited for a response. I put two buttons on the form, one put "no" in a text box, the other put "yes", and both buttons caused the form.visible to be false
>
> the report open event checked for no in the text box on the popup form. If it was no, cancel set to true and it closed the hidden form. If it was yes then the report opened normally and closed the form.
>
> Both scenarios worked fine using basically the same code you used below, so check to make sure another event (close or unload) isn't closing the form. Beyond that I'm out of ideas. :(
>
> --- In MS_Access_Professionals@yahoogroups.com, "Lee" <leevt99@> wrote:
> >
> > Yes you can close a form that is hidden, I do it all the time using the same code so I know that's not the issue: DoCmd.Close acForm, "FormName"
> >
> > Nothing jumps out to me in what you posted so far, but one of the big guns might be able to see something I'm missing.
> >
> > You can try testing it without making the form invisible, if you can see that form and still get the error then something else is going on. If the form closes and you still get the error, then something else may be closing it before it hits the code you posted below, etc.
> >
> >
> > --- In MS_Access_Professionals@yahoogroups.com, "glcass58" <glcass58@> wrote:
> > >
> > > Thanks for your help. Your logic makes sense. The one problem I'm having is that I get error 2450 Access can't find the form referred to... Can I close a form that's not visible? I don't *think* it's a typo.... I do have a typo in my original posting- there is no L at the end of the form name and I do not have the L in my code...
> > >
> > > Dim AskCancel As Integer
> > > AskCancel = MsgBox("Are you sure you want to cancel?", vbQuestion + vbYesNo, "Question")
> > > If AskCancel = vbYes Then
> > > Me.Visible = False
> > > etc...
> > >
> > > If Forms![Params_AdminStatusRpts].[txtWhereClause] = "" Then
> > > DoCmd.Close acForm, "Params_AdminStatusRpts", acSaveNo
> > > Cancel = True
> > > End If
> > >
> > > I've tried making txtWhereClause be null or have the word "cancel" in it. I'm just not sure what I'm doing wrong.
> > >
> > > Thanks again for your help.
> > >
> > > --- In MS_Access_Professionals@yahoogroups.com, "Lee" <leevt99@> wrote:
> > > >
> > > > Oh and I would use the cancel button to make the parameter form invisible, rather than closing it. Then close the parameter form from the report_open event if cancel = true.
> > > >
> > > > Or you can use cancel to set the txtWhereClause control to something like "User Canceled" and then have the Report_open event check for that and then set cancel = true if something is there.
> > > >
> > > > --- In MS_Access_Professionals@yahoogroups.com, "Lee" <leevt99@> wrote:
> > > > >
> > > > > Check the txtWhereClause control for a value before setting the recordsource, if there's nothing there, set Cancel=True in the Form Open event
> > > > >
> > > > > --- In MS_Access_Professionals@yahoogroups.com, "glcass58" <glcass58@> wrote:
> > > > > >
> > > > > > 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

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


A Bad Credit Score is 600 or Below. Your Score? Find out at freecreditscore.com.
.

__,_._,___

Tidak ada komentar:

Posting Komentar