Interesting Requery problem (1 Viewer)

sarahb845

Registered User.
Local time
Today, 12:51
Joined
Jun 19, 2002
Messages
43
Actually, I don't know for sure if it is a requery problem....

Here's the situation:
I have a form that allows the user to select a report from a listbox, and manipulate parameters that will be used when generating the report. At the bottom of the form there are command buttons - Print, Preview, and Refresh Default Values. The user can manipulate several parameters and run a report several different times. At some point, they might want to reset all of the parameters back to their default values - that is what the Refresh Default Values command button is for.

My problem is not with the actual code of the requery (the values on the form are reset), but what happens to a particular report after requering the default values.

Here's what happens:
1) Select the report "Performance Management Detail" in the listbox.
2) Only parameters available for the report are shown. All of the parameters have default values.
3) Preview the report (whether using the defaults or customizing it) - WORKS!
4) Close the report (taken back to the reports form) and change some parameters.
5) Preview the report again with the changed parameters - WORKS again!
6) Close the report (back to reports form again) and click on the Refresh Default Values command button. All parameters are reset.
7) Preview the report again with parameters requeried - DOES NOT WORK! (However, if I close the form and re-open, the report will run.)

The error that I get at this point is: "The expression is typed incorrectly, or it is too complex to be evaluated. For example, a numeric expression may contain too many complicated elements. Try simplifying the expression by assigning parts of the expression to variables."

-----

Here is the code that is used to requery parameters (only one parameter is shown - all others are similiar):

Public Sub cmdResetDefaults_Click()
'Requery Start and End Review Dates

Forms!frmReports!frmReportsSUB.Form!txtStartReviewDate = Forms!frmReports!frmReportsSUB.Form!txtStartReviewDate.DefaultValue

Forms!frmReports!frmReportsSUB.Form!txtStartReviewDate.Requery

Forms!frmReports!frmReportsSUB.Form!txtEndReviewDate = Forms!frmReports!frmReportsSUB.Form!txtEndReviewDate.DefaultValue

Forms!frmReports!frmReportsSUB.Form!txtEndReviewDate.Requery

End Sub

----

What I don't understand is why the report will preview, except after requering the default values? Is there some sort of memory bloat that happens when requering? What can I do to fix???
 
Last edited:

bradcccs

Registered User.
Local time
Tomorrow, 05:51
Joined
Aug 9, 2001
Messages
461
Great problem description!

I am guessing that you have checked that the fields are actually returning to the default values.

As a problem solving venture, I would firstly comment out the resetting of the date parameters, and just reset the "easy" ones.

Then:
Continue to comment out the resets until you can comment out no more :)

When all else fails, you could cheat:

docmd.close
docmd.openform "OpenSameFormAgain" 'Vales reset - Magic!

Goodluck

Brad.
 

sarahb845

Registered User.
Local time
Today, 12:51
Joined
Jun 19, 2002
Messages
43
Problem solved! - here's what I did to fix:

Date range parameter textboxes were causing the problem. The default value in the textbox properties was left blank. (I do not want anything to appear in the textboxes on open. The field that these textboxes are affecting could contain null dates. To set a default date range would not include the records with the null date, which is not what I want.)

So, to fix the problem I changed the default values for each textbox to Null. I thought that would be enough. The form loaded correctly on open - with the textboxes blank. However, after I requeried, each textbox had the word Null in it, instead of being blank. Again, the report did not run.

So, then I altered the code by removing the reference to the field's default value, and set the fields to Null:

Public Sub cmdResetDefaults_Click()
'Requery Start and End Review Dates

Forms!frmReports!frmReportsSUB.Form!txtStartReviewDate = Null

Forms!frmReports!frmReportsSUB.Form!txtStartReviewDate.Requery

Forms!frmReports!frmReportsSUB.Form!txtEndReviewDate = Null

Forms!frmReports!frmReportsSUB.Form!txtEndReviewDate.Requery

End Sub

--------

I'm not really sure why resetting my field to its default value (either blank or Null) did not work. Does anyone have any knowledge about this????????????
 

Users who are viewing this thread

Top Bottom