Save New Default Value on exiting form

  • Thread starter Thread starter dg
  • Start date Start date
D

dg

Hi all

I have been asked to get an unbound text box on a form to remember the last
value entered. Thus when the form is restarted the value in the textbox is
the last one used.

(The text box is used to store a title which is displayed on a report)

I have tried setting the defaultvalue of the textbox on closing the form to
the new value and using docmd.save command to automattically save the form.
But this doesnt work. I have also tried using the on_lost_focus on the text
box to set the default value. this doesnt work either.

Any assistance would be appreciated.

Thanks

D.
 
To save the default value for your controls, you would need to change the
form into design view, set the values, and then save it.

A better alternative might be to use the Unload event of the form to save
the Default Value settings for the controls in a table. Next time, you use
the Load event of the form to read the values from the table, and assign
them to the controls again.

There is an example of how to set up such a table, and use the Unload and
Load events in this article:
http://allenbrowne.com/ser-18.html
The article actually explains how to save the primary key value to return to
the same record again next time, but the principle is the same.
 
Thanks

I will give it a try


Allen Browne said:
To save the default value for your controls, you would need to change the
form into design view, set the values, and then save it.

A better alternative might be to use the Unload event of the form to save
the Default Value settings for the controls in a table. Next time, you use
the Load event of the form to read the values from the table, and assign
them to the controls again.

There is an example of how to set up such a table, and use the Unload and
Load events in this article:
http://allenbrowne.com/ser-18.html
The article actually explains how to save the primary key value to return
to the same record again next time, but the principle is the same.
 
Back
Top