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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pasting Preset Text into text box using command button

Status
Not open for further replies.

laserman09

Technical User
Apr 29, 2004
7
US
I have a couple standard texts that I use frequently, and don't want to type them every time into the text box. Is there a way to code the command button to paste text into a text box, and not overwrite what's in the box. For example, if I had 3 different buttons with different preset texts, is it possible to make then so that I could click each of them and they would just add text one after another into the text box?
 
Different solutions.
To add a text without space
Code:
Private Sub Command2_Click()
Me.Text0 = Me.Text0.Value & "My New Text"
End Sub
To add a text with space.
Code:
Private Sub Command2_Click()
Me.Text0 = Me.Text0.Value & " " & "My New Text"
End Sub
To add a text with selected text anywhere in the text box
Code:
Private Sub Command2_Click()
Me.Text0.SetFocus
Me.Text0.SelText = Me.Text0.SelText & "My New Text"
End Sub
To add a text with selected text anywhere in the text box with space
Code:
Private Sub Command2_Click()
Me.Text0.SetFocus
Me.Text0.SelText = Me.Text0.SelText & " " & "My New Text"
End Sub
hoep this helps

Zameer Abdulla
Visit Me (New Look & style)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top