Add textbox to userform issue

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,738
Office Version
  1. 2007
Platform
  1. Windows
Hi,
I have a working userform & require a text box just so i can add some brief notes.

I have added the text box to the form ok & written some text into it.
I save it all ok but when i then go back to this customers records on this form i dont see the text that was written ?

My info for all the fields on the userform come from a database,does that mean that the text i wish to see in this text box needs to be entered onto the database also ?

Or if possible i just need to be able to write a line or two & save without the database side of things.

Thanks please advise.
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Writing into a textbox, then closing the textbox, will result in losing the textbox text. If you want to see the text again, it should be stored somewhere on the sheet, then when you show the userform, you can populate the textbox with the stored range.

For a simple example.

Userform has a textbox1
enter something in textbox1 and when you exit textbox1 the value with go to A1
When you show the userform again, the textbox will be filled in whatever is in textbox1

Code:
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    Range("A1") = Me.TextBox1
End Sub

Private Sub UserForm_Initialize()
    Me.TextBox1 = Range("A1").Value
End Sub
 
Upvote 0
Thanks,

I have two of the same names so how should your code be included with what is currently in place.
The text box of which i will write notes in will be on each customers records.
Not all records will have notes but will one note for one customer just overwrite another note ?


Code:
Private Sub UserForm_Initialize()    Me.TextBox1 = Range("A1").Value
End Sub

Code:
Private Sub UserForm_Initialize()    Set ws = ThisWorkbook.Worksheets("Database")
    
    ComboBoxCustomersNames_Update




    ResetButtons False
    'start at first record
    Navigate Direction:=xlFirst
    
End Sub

Thanks for your time.
 
Upvote 0
Writing into a textbox, then closing the textbox, will result in losing the textbox text.
Not necessarily. If you place a TextBox on a UserForm and then do a slow double click into the TextBox, you will see a blinking text cursor appear... you can type anything you want into the TextBox and it will remain there once you save the workbook and still be there next time you reopen the workbook.
 
Upvote 0
Thanks for the advise davesexcel,
That works fine if i had 1 entry in my form.
As soon as i type in the text box for another customer it then overwrites it thus saving to A1.

I need something that will allow multiple saves etc without overwriting each time.
The saved note must stay with that customer
 
Upvote 0
I know what i need to do but i can find the correct place to edit the code.

My range in the database is A:P i then need to put the note into Q so when the userform is open the info in Q will then be matched with the rest of the records in that row.

Do i look in the database code or the userform code to make the edit ???
My head hurts......
 
Upvote 0
Not necessarily. If you place a TextBox on a UserForm and then do a slow double click into the TextBox, you will see a blinking text cursor appear... you can type anything you want into the TextBox and it will remain there once you save the workbook and still be there next time you reopen the workbook.

Since OP has mentioned the text disappears, my assumption would be that the text is being filled in when the userform is showing, not in the vba editor
 
Upvote 0
I was using range("A1") as an example to show how to place the textbox info onto the sheet and how to retrieve it when you show the userform again.

More info may have to be provided for a more details answer.
 
Upvote 0
Hi,
Thanks all for your time.

I have now uploaded a file to google drive.

https://drive.google.com/open?id=11kug87KVacCa_ADFT9xGsYpvx7XcZMnD

If you go to the sheet DATABASE then select OPEN you will see the textbox on the right.

In my database i have now added column Q for where the notes will be written against that customer in that row.

When i then scroll through the customers in the userform i should see the text for each customer be shown.

I know what i need to do but i cant put my finger on it.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,327
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top