Getting unbound text boxes to print with something other than their default value

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • topher23
    Recognized Expert New Member
    • Oct 2008
    • 234

    Getting unbound text boxes to print with something other than their default value

    Disclaimer: I've already come up with a solution for this issue, but I thought I'd post it in the hope that it could help someone else and on the off chance that someone has another solution.

    I have a form for machine operator tracking. The form shows training-stage tracking dates with a lot of performance information. On the form is a subform for reviews, which uses a set of unbound text boxes to show current data for a review, which is unsaved until the supervisor adds comments and clicks a "submit" button, which then adds the data (with comments) to a reviews table.

    The unbound text boxes each have an IIf statement as the default value, which references values on the parent form. However, if the required stage tracking review has already been completed, code in the On Open event runs to calculate the performance data from the last review to the most current data for the machine operator. This new data is displayed in the unbound text boxes.

    Everything worked fine, with all of this new data properly displayed, until the supervisor went to print the form. When the form printed, all of the default values printed out, even thouth the new data was still on-screen.

    First, I tried removing the default values and assigning values for each textbox in code: this was a fiasco. Suddenly, nothing at all showed up, in form view or on the printout. So, I tried assigning default values in code: again, nada. Then I got creative - I put the old default values back on the textboxes, then used the code only to change the default value to the new values if necessary. Amazingly, this worked, and the best part is that this default value only remains default while the form is open, since the change wasn't made in design view but in form view.

    Has anyone else run into this? Anyone have a better solution?
  • yarbrough40
    Contributor
    • Jun 2009
    • 320

    #2
    You know I remember running into this a couple of years ago but it wasn't when printing but rather simply referencing the newly typed textbox value in a button click. I remember that instead of getting the new value which I could clearly see, I was getting the default value. I do not remember the solution I came up with but I think I may have ended up using a different event other than click. It may have been form unload or deactivate or something.... anyway - this is good stuff, thanks for posting!

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32656

      #3
      That's exactly what I would have done. The print seems to print off the bare form with the attached recordset data. This would not include any unbound data. If the Default value is being printed, then exactly what you did (replaced that with code rather than relying on the .Value) is the fix.

      Beware though, if this is done in continuous mode then the change will effect the control for each record instance that it's attached to. IE. It will repeat through the print for each occurrence.

      This is related to the issue in Why Values in Unbound Form Controls do not Persist.

      Comment

      Working...