default value from VBA

  • Thread starter Thread starter adam
  • Start date Start date
A

adam

Hi, I want the users to change the default value of
a "text box" on a form. My code works fine for the
initial use, but when you open the form again, control's
old value remains the default value. My code is like :

Forms!Form1.TextBox1.DefaultValue = .....

Note : Table does not have any default value for that
field

Thanks for help
 
Unless the form was in design view, the value you assign to the DefaultValue
of a control will not survive between sessions.

You could save the last DefaultValue into a different table when you close
the form, and use its Open event event to assign the DefaultValue property
again. This article explains how to save the value of a control to a table
and reload it next session. You could modify the example to save the load
the DefaultValue string instead:
http://allenbrowne.com/ser-18.html
 
when you open the form again, control's
old value remains the default value. My code is like :

Forms!Form1.TextBox1.DefaultValue = .....

If you have a persistent method of storing the required DV, you can put
this code in the OnOpen or OnCurrent events of the form.

Using the OnCurrent event is a common way of "carrying" values over from
the previous record.

Hope that helps


Tim F
 
Back
Top