How to save the last value of a textbox.

diakis

Registered User.
Local time
Tomorrow, 01:36
Joined
Jul 4, 2006
Messages
16
I have a textbox that takes a lot of values. I want when I close the form or the application to save the last value and when I open the form or the application this textbox to show the saved value. Something like a high score in a game. Thank you
 
Have a value available in a table for this, in the on close of your form run an update query to set this to the value in your unbound textbox.

In the form on open set the value of the textbox to the content of the table.

This way it always opens with the last stored value and then when you edit it and close the form it updates the stored value ready for next time.
 
Is this text box bound to a field in a table? If that's the case do you want the form to open displaying the record it was displaying when it was closed?
 
Code:
Private Sub Form_Close()
'Set the default value for textbox
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE table SET table.field = [Forms]![FormName]![Textbox] " & vbCrLf & _
"WHERE (((table.ID)=1));"
DoCmd.SetWarnings True

End Sub

Private Sub Form_Load()
'Load the default value for textbox
Me.Textbox.Value = DLookup("[field]", "[table]", "[ID]=1")
End Sub
 
Last edited:
You may notice I just removed all my errors:o
 

Users who are viewing this thread

Back
Top Bottom