TextBox Default Values - How do I change and hold the value?

J

John Dempsey

I have a Textbox that asks for a username. When they put that Username
in, do the processes and close the form when it opens again the value
is blank. If on Design View I change the Value it stays there
permanently even if someone changes it. I need a way to update the
form so that when they change it it retains the changed value on
reopening.

Please help, its driving me bonkers.

Thanks John
 
S

Sue Mosher [MVP-Outlook]

Sounds like you didn't bind the text box to an Outlook property. You should
do that if you want to retain the data in the item. Use the Value tab on the
control's Properties dialog.
 
J

John Dempsey

They just input it on the form the first time and then I have tried to
set the value but when I reload the form it does not retain it. In
design mode if I change the Properties it retains it but how do I update
to keep that proertiy stored.

So the process is:

Form Displays
AfterUpdate - set textbox6.value to new value
Close Form
Open Form again. - textbox6 is back to nothing.

Code below:

Private Sub TextBox6_AfterUpdate()

szTextBox6 = UserForm5.TextBox6.Value
UserForm5.TextBox6.Value = szTextBox6

End Sub

How do I retain it?

Thanks in advance.

John D
 
S

Sue Mosher [MVP-Outlook]

What's this about? The newsgroup interface you are using apparently does not
quote earlier messages in the thread, making your latest message so short on
detail that you risk not getting the answer you're looking for. Please take
the time to quote the original message.

This looks like VBA userform code, not Outlook form code. Where do you want
to store the data?
 
J

John Dempsey

They just input it on the form the first time and then I have tried to
set the value but when I reload the form it does not retain it. In
design mode if I change the Properties it retains it but how do I update
to keep that proertiy stored.

So the process is:

Form Displays
AfterUpdate - set textbox6.value to new value
Close Form
Open Form again. - textbox6 is back to nothing.

Code below:

Private Sub TextBox6_AfterUpdate()

szTextBox6 = UserForm5.TextBox6.Value
UserForm5.TextBox6.Value = szTextBox6

End Sub

How do I retain it?

Thanks in advance.

John D
 
S

Sue Mosher [MVP-Outlook]

Repeating: This looks like VBA userform code, not Outlook form code. Where
do you want to store the data?

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
J

John Dempsey

OK I will post to there but it was Outlook VBA I was writing, but the
forms where VBA so I will post. Thanks anyway.
 
S

Sue Mosher [MVP-Outlook]

You still haven't answered the key question: Where do you want to store the
data? A userform is just a dialog. It has no data storage capability.
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
J

John Dempsey

I want to store the data in the VBA form. The textbox has a default
value that I need to store. I will try storing the data in a text file
and read the text file using filesystemobjects.

Is there anywhere else I can store the data?
 
S

Sue Mosher [MVP-Outlook]

A text file would be a good choice. Depending on the data, a database might
be another. Or the Windows registry. Or in an Outlook item. But you cannot
store data in a VBA userform itself.

You haven't said anything about the application itself. Does the data need
to be retained between Outlook sessions? If so, use one of the locations
above. If not, hide your form instead of unloading it, so the control values
will remain accessible.
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
J

John Dempsey

Thank you Sue. This was very helpful. It does need to be retained and I
can use the text file for a few different data, not enough to warrant a
database. The sensible answer is the text file then I can user define.

Thanks ever so much for your help.

Regards

John D
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top