saving default value for a text box

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

I'm using a text box for notes (it's not associated with any tables). When
user entered some text there I'd like that this text would appear on the next
time when user would open this form.

I'm trying to use the following:

Private Sub PrintHeaderText_AfterUpdate()
Dim new_text As String
new_text = Me.PrintHeaderText
Me.PrintHeaderText.DefaultValue = "'" & new_text & "'"
End Sub

.... and the following code:

Private Sub CloseButton_Click()
DoCmd.Close acForm, Me.Form.Name, acSaveYes
End Sub

But when I open the form again the text in the text box is not updated
Could anybody advise anything?

Thanks
 
Mike

I seem to recall that you have to use the .Value property of an unbound
textbox to get the value that was entered.

Maybe you could try (untested):

new_text = Me!PrintHeaderText.Value

This assumes the name of the control you are using is [PrintHeaderText].

Good luck!

--
Regards

Jeff Boyce
www.InformationFutures.net

Microsoft Office/Access MVP


Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/
 
Thank you, Jeff, for the answer!
But unfortunately that didn't help. When I open the form again the text in
the text box is still not updated.





Jeff Boyce said:
Mike

I seem to recall that you have to use the .Value property of an unbound
textbox to get the value that was entered.

Maybe you could try (untested):

new_text = Me!PrintHeaderText.Value

This assumes the name of the control you are using is [PrintHeaderText].

Good luck!

--
Regards

Jeff Boyce
www.InformationFutures.net

Microsoft Office/Access MVP


Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/

Mike said:
I'm using a text box for notes (it's not associated with any tables). When
user entered some text there I'd like that this text would appear on the next
time when user would open this form.

I'm trying to use the following:

Private Sub PrintHeaderText_AfterUpdate()
Dim new_text As String
new_text = Me.PrintHeaderText
Me.PrintHeaderText.DefaultValue = "'" & new_text & "'"
End Sub

... and the following code:

Private Sub CloseButton_Click()
DoCmd.Close acForm, Me.Form.Name, acSaveYes
End Sub

But when I open the form again the text in the text box is not updated
Could anybody advise anything?

Thanks
 
Mike

Perhaps one of the other newsgroup readers has solved this...

Good luck!

--
Regards

Jeff Boyce
www.InformationFutures.net

Microsoft Office/Access MVP


Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/

Mike said:
Thank you, Jeff, for the answer!
But unfortunately that didn't help. When I open the form again the text in
the text box is still not updated.





Jeff Boyce said:
Mike

I seem to recall that you have to use the .Value property of an unbound
textbox to get the value that was entered.

Maybe you could try (untested):

new_text = Me!PrintHeaderText.Value

This assumes the name of the control you are using is [PrintHeaderText].

Good luck!

--
Regards

Jeff Boyce
www.InformationFutures.net

Microsoft Office/Access MVP


Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/

Mike said:
I'm using a text box for notes (it's not associated with any tables). When
user entered some text there I'd like that this text would appear on
the
next
time when user would open this form.

I'm trying to use the following:

Private Sub PrintHeaderText_AfterUpdate()
Dim new_text As String
new_text = Me.PrintHeaderText
Me.PrintHeaderText.DefaultValue = "'" & new_text & "'"
End Sub

... and the following code:

Private Sub CloseButton_Click()
DoCmd.Close acForm, Me.Form.Name, acSaveYes
End Sub

But when I open the form again the text in the text box is not updated
Could anybody advise anything?

Thanks
 
When you change the default value of the text box, it is only used for the
currently open version of the form. Even though you use acsaveyes on the
close, the form was not opened in Design View, so the change is not saved.

Try defining new_text as a global variable in a module (not a form module),
then in the On Close event of the form put:

new_text = Me.PrintHeaderText

and in the On Open event put:

Me.PrintHeaderText = new_text

John
 
Mike said:
I'm using a text box for notes (it's not associated with any tables). When
user entered some text there I'd like that this text would appear on the
next
time when user would open this form.

I'm trying to use the following:

Private Sub PrintHeaderText_AfterUpdate()
Dim new_text As String
new_text = Me.PrintHeaderText
Me.PrintHeaderText.DefaultValue = "'" & new_text & "'"
End Sub

... and the following code:

Private Sub CloseButton_Click()
DoCmd.Close acForm, Me.Form.Name, acSaveYes
End Sub

But when I open the form again the text in the text box is not updated
Could anybody advise anything?

Thanks

I think you need to use Chr$(34) instead of "'" around the new_text
variable.
 
Back
Top