Make unbound (txtBox) remember its last value

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,
I have an unbound text box on my form, every time I enter a number
(currency) it stays there while the form is opened. When I close and open the
Form, the txtBox’s value is gone (loses the last/previous numbers the were
entered in it).
I do not want to set a default value numbers coze I change it once every week.
My question is how to make this unbound (txtBox) remember its value?

Thank you all,
Adnan
 
Set the default using code tied to the afterupdate event. Then, every time
you change the entry, it will write your entry to the default.
 
Rick,
That was close, I wrote this code on after update:

Private Sub txtRateChange_AfterUpdate()
Me.txtRateChange.DefaultValue = Me.txtRateChange
DoCmd.Save
Me.Profession.SetFocus
End Sub

This will still not save the value, when I close the form the value is gone
(emptied).
What would you prefer adding/removing?

Thank you,
Adnan

--
Please post all your inquiries on this community so we can all benefit -
Thank you!


Rick B said:
Set the default using code tied to the afterupdate event. Then, every time
you change the entry, it will write your entry to the default.
 
There are many posts related to this topic in the formscoding newsgroup. Go
take a look at these. Most include sample of the code...

http://groups.google.com/groups/search?hl=en&q=set+default+after+update

--
Rick B



Adnan said:
Rick,
That was close, I wrote this code on after update:

Private Sub txtRateChange_AfterUpdate()
Me.txtRateChange.DefaultValue = Me.txtRateChange
DoCmd.Save
Me.Profession.SetFocus
End Sub

This will still not save the value, when I close the form the value is
gone
(emptied).
What would you prefer adding/removing?

Thank you,
Adnan
 
I think the post that you are looking for is the second one in the list. It
says...

----------------------------------------------------------------------------
Barbara
Add the following to the Combo's AfterUpdate event;
Me.comboName.DefaultValue = Chr(34) & Me.ComboName & Chr(34)
HTH
Andy
----------------------------------------------------------------------------


Adnan said:
Rick,
That was close, I wrote this code on after update:

Private Sub txtRateChange_AfterUpdate()
Me.txtRateChange.DefaultValue = Me.txtRateChange
DoCmd.Save
Me.Profession.SetFocus
End Sub

This will still not save the value, when I close the form the value is
gone
(emptied).
What would you prefer adding/removing?

Thank you,
Adnan
 
Anyone any help on this please?

How would the text get saved on a text box (unbound) when the form
opens/closes it still remains the same (do not want tables to get involved on
this please)

Any thought/tip/help is greatly appreciated!
v/r
Adnan
 
As far as I know it can't be done. I tried it with the unbound textbox, I
tried using it to change the caption on a label--none of those changes are
saved when the form is closed. I'm thinking you'll have to add a field to
the underlying table. But really, what's the big deal about doing that?
 
Perhaps if you could explain why it has to be an unbound textbox, rather
than bound to a table, we could offer an alternative.
 
On this form, I have already a table as a row source --- You’re telling me to
use another table just for a little txtBox? Well, I guess since there isn’t
any other alternative then that’s what I’m gone have to do. Ricter, I do
appreciate your time, though.
v/r
Adnan
 
It does raise the question of how to store a single value, that is, one
record only, ever, with no "history". Some kind of query to always overwrite
the previous value, I'm not sure...
 
Well, you can't have more than one table as a row source.

You'd either need to create a query that joined the two tables together or,
if that's not possible, use a subform on the main form.
 
Back
Top