Temp Form holds previous values

  • Thread starter Thread starter JDC via AccessMonster.com
  • Start date Start date
J

JDC via AccessMonster.com

I am having difficulty finding a way to reset/refresh the fields on a
temporary form to their default values.

When I call a report I have a temp form load from the Reports On Open
Event, this temp form has a few fields that help the end user narrow the
report. The temp form has a few default values loaded like a date field
using =Date().

The first time I run the Report, the temp form loads with the default
values like it is supposed. Lets say I change one of the default values
(like date from the suggested todays date to yesterday's) and run the
report everything works perfectly. However the next time I run the report
the temp form loads with the values I previously used.

Other Info items, when the Report is open the temp form is hidden, when I
close the report it closes the hidden temp form.

I have tried several of the ways obvious tom to refresh this form On Load,
On Open and On Focus without success. Any suggestions you all have to
reset the values in each field to the Default Properties would be greatly
appreciated.

(Hope the above made sense),
Thanks
 
Is the form bound to a data source? I don't think it should be. If not,
what code do you use? How are you opening this form, how are you using its
values in the report source, and how do you close it?
 
The form is not bound to a data Source.
The Form opens with:
Private Sub Report_Open(Cancel As Integer)
' Set public variable to true to indicate that the report
' is in the Open event
bInReportOpenEvent = True

' Open Temp Form Dialog
DoCmd.OpenForm "TempForm", , , , , acDialog

' Cancel Report if User Clicked the Cancel Button
If IsLoaded("TempForm") = False Then Cancel = True

' Set public variable to false to indicate that the
' Open event is completed
bInReportOpenEvent = False
End Sub

The values are used by the query the report is built on. The query
references the feilds on the form and are passed appropriatly to the Report.

The Form is closed with the following:
Private Sub Report_Close()
DoCmd.Close acForm, "TempForm"
End Sub

I just realized and corrected the problem (I think). I had a typo on the
form name On Close, so the hidden form was not really closing thus keeping
the values.

Thanks, sometimes I think it just helps to spell/verbalize before you find
your answer. Nothing like looking at something too long!
 
Hmmm. I'd check the on close event for any typos. It might be that the
form isn't actually closing.

(I love giving answers that are guaranteed to be correct :)

Well done on working it out for yourself.
 
Back
Top