Clearing form

  • Thread starter Thread starter Stephanie
  • Start date Start date
S

Stephanie

Hi. I have an input form that is used by 2 reports- input
from the first report is past to the second report. The
first report has a msg box asking if the user wants to go
to the second report. If no, the input form closes.
However, the input form retains the user input. The form
is DateParam and the field is FindDate

I tried a requery OnClose of the form (FindDate.Requery),
but that didn't work. Any suggestions? Thanks, Stephanie
 
Are the controls in that input form bound to fields in a table? If yes,
delete the form's RecordSource; using unbound controls is normally the
approach used for forms that gather data to be used by queries and reports.
 
I think that you clear it in the report ON CLOSE event.

You might look at the Northwinds database. It uses a parameter form to call
several reports and I know they are cleared out when you run a new report.

I'd check the report code to see if it clears and closes the parameter form.

Rick B
 
DateFind is an unbound field in form DateParam. My
second report contains:

Private Sub Report_Close()
DoCmd.Close acForm, "DateParam"
End Sub

Could I also have the second form clear DateFind? What
would that look like?

I did try to clear DateFind on the OnClose event of
DateParam itself: Me.DateFind.Requery which seems wrong
and is! Can this be done? Which is better? Thanks,
Stephanie
 
Thanks for the tip.
-----Original Message-----
I think that you clear it in the report ON CLOSE event.

You might look at the Northwinds database. It uses a parameter form to call
several reports and I know they are cleared out when you run a new report.

I'd check the report code to see if it clears and closes the parameter form.

Rick B

Stephanie


.
 
What second form? You mean the popup message one? Is that a form or a
message box? Either way, yes, it would be possible to have it close the
DateParam form if the person says he/she doesn't want the second report.

In the code in the first report, assuming that you're using a message box:

If vbNo = MsgBox("Do you want the second report?") Then
DoCmd.Close acForm, "DateParam"
Else
DoCmd.OpenReport "SecondReport"
End If
DoCmd.Close acReport, Me.Name
 
Sorry for not being clear.
My Volunteering report calls DateParam. User enters date
into FindDate (an unbound field). Volunteering runs, and
OnClose asks the user if they want to run Labels. If
yes, Volunteering report closes, Labels report runs and
the FindDate field on DateParam gets cleared out. If
user says "no", Volunteering closes. Then when I
manually open DateParam, FindDate still "holds" the user
entered date.

So, both reports close. It's just that FindDate
doesn't "refresh" if the user chooses not to run the
Labels report. So I thought that when DateParam closes,
I'd like FindDate to be blank.
Thanks,
Stephanie
 
What you describe suggests to me that you're not actually closing DateParam
form; rather, your code appears to be just making it invisible and then,
when you manually "open" it, you make it visible again (you're not really
opening it) so the value that was in the control is still there.

Two options:
(1) Actually close the DateParam form in your code.
(2) Set the value of the FindDate control to Null in the code that is
"closing" the form; do this before you "close" the form.

Forms!DateParam!FindDate = Null
 
Of course, you are correct. I "hid" DateParam to pass
the value. Forms!DateParam!FindDate = Null worked
beautifully! Thanks, Stephanie
 
Back
Top