Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Textbox String Won't Save When Form Closed

Status
Not open for further replies.

hdog

Technical User
Mar 24, 2002
26
US
I have written some code that prompts for input and then passes the results to an unbound text box. I have included code to keep the old result if there is no new data entered or if cancel is selected. All works fine except when the form is closed and reopened. Once reopened, the unbound text box no longer contains the text string that was there previously, eventhough the form data was saved. What am I doing wrong?
 
You say the data is 'stored' - but WHERE is it stored and how does the UNBOUND text box know of the existance of this stored data when the Form first opens?

It sounds to me like you need some code on the Form_Open event to populate the Unbound text box with the 'Stored Data' or simply Bind the text box to the field where this data is stored.


G LS
 
Data in an unbound textbox will not be stored anywhere unless you tell it to be stored somewhere by binding it to a field in the table or capturing it into a global variable.
Pat B
 
Yes, I see what you mean. At present I'm not passing the string in my unbound text box to a table. How do I pass the information from the unbound text box in my form to a table record? I was thinking of using two fields in a table: Type and Path. The "Type" would be a unique descriptor and the "Path" would be the path to a directory of .jpg's to be displayed.

Or is there another way of just posting a text string on the form as a hidden text/label field that could then be updated from my input box and saved with the form when closed?

I'm trying to keep this as simple as possible. I'm just getting my feet wet in VB and would appreciate any help you could give me.

Thanks!
 
If you want it as simple as possible bind the text box to a field in the appropriate table. Then when you enter a value it will automatically be saved to the table and when you open the form, the value in the table will automatically be displayed. That way you won't need unbound text boxes nor hidden fields. (There may be a reason that you need an unbound text box, but off-hand I don't see it.)

If you really want simple create your table to hold the two fields and use one of the form wizards to make a bound form for you. "The Key, The Whole Key, and Nothing But The Key, So Help Me Codd!"
 
I do not quite see the need for the text box to be unbound either. However if there is a good reason for it to be unbound (and there could be), then I would create another text box that is bound to the field in the table. Set the new textbox's visible property to false. Then you can update the invisible bound text box through code.

Pat B
 
Thanks for the help. I got it running!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top