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

buttons that insert and edit text

Status
Not open for further replies.

tedmillerx

Programmer
Jan 6, 2001
52
US
I'm designing a cooking database for elderly who prefer to mouse instead of type. I want to build 30 buttons and combo boxes in a small pop up form that have the most common words they'll use to insert into a single memo field on a second form.

my form "frmRecipes" reads/writes directly to a table "tblRecipes". the pop up form is called "frmSymbols".

questions:
1. I've tried writing update queries to do this, but that's a lot of queries. also, I'm having a hard time getting frmRecipes to show the updates after clicking a button in frmSymbols. does doing this with update queries make sense? if so, how do I refresh frmRecipes?

2. Is there a more elegant way to do this in VBA?

3. How do I get the text to insert right where you leave the cursor, and not at the end of the field?

thanks in advance for any help!

 
Hi there,

I am not sure about the design benefits of this but you could try on your pop up form to have command buttons like so.

Private Sub Butter_Click()
Forms!Recipe!MemoFieldName = Forms!Recipe!MemoFieldName & " " & "Butter"
End Sub

Unfortunately, this will put the data at the end of the memo field.

HTH.

Peter.




Remember- It's nice to be important,
but it's important to be nice :)
 
thank you! that solves much of my problems.

two additional questions:
what's the code for inserting a return into a memo field using a button?
how do I delete the last character of a memo field?

basically, I want to have an "Enter/Return" button to go to a new line and a "Backspace" button.
 
Hi there,

Here is the command button code for "backspace"

Private Sub Command2_Click()
Dim memostring As String

memostring = Forms!menu!Memo.Value

memostring = Left(memostring, Len(memostring) - 1)
Forms!menu!Memo = memostring

End Sub

This code should do the carriage return.

Private Sub Command3_Click()
Dim memostring As String

memostring = Forms!menu!Memo.Value
memostring = memostring & vbNewLine

Forms!menu!Memo = memostring

End Sub

Good luck with it!

Peter.

Remember- It's nice to be important,
but it's important to be nice :)
 
sweet! I've implemented your first solution and it worked great! I can't wait to see how this works.

Thanks, Peter!

ted
 
I got the backspace and carriage return to work too! Thanks again, Peter.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top