Add text string to existing field by clicking button

  • Thread starter Thread starter stevee2002
  • Start date Start date
S

stevee2002

I'm a newbie, gotta simple question:
I need to add text strings to an existing memo field by clicking a button.

PURPOSE:
In need of a WorkOrder/ServicePerformed sheet for customers.
I am entering the data into a form, then printing a report.
I use repetative strings such as "Removed Viruses" and "Cleaned Computer" on
all Work Orders
I would like to have pre-designated buttons that will append strings of text
TO THE SAME FIELD.

I understand the basics of form creation etc, i just don't know what command
or code to insert into the OnClick event procedure.

Any ideas or help would be appreciated.
 
I would create a small table "tblStrings" with a single text field
"TheString". Add a list box on your form that has a Row Source property of
"tblStrings". This will display the strings that can be add to the text box.
Then add code to the On Double-Click event of the list box like:

Private Sub lboStrings_DblClick(Cancel As Integer)
If InStr(Me.txtToTheSame & "", Me.lboStrings) = 0 Then
Me.txtToTheSame = Me.txtToTheSame & " " & Me.lboStrings
End If
End Sub

This assumes your list box is named "lboStrings" and your memo field is
bound to a text box named "txtToTheSame".

I would probably not create a solution like this. I would store the Work
Performed in a separate related table rather than concatenating these values
into a single memo field.
 
I don't have all the necessary details to provide you with the exact code for
your database, but here is an example to demonstrate the concept.

Let say you have a form with 2 text controls named 'Name' and 'Comments'
and a button named 'Add_Comment'.

Case1
We want to add 'Entry Created {Todays date}' to the top of the 'Comments'
control, we would do somthing like:

Me.Comments="Entry Created " & Date() & vbcrlf & Me.Comments

So you understand, what we are doing is stating make the content of the
control 'Comments' equal to the text "Entry Created " and add today date,
then goto the next line add put whatever was already in the control.

Case2
We want to copy the value of the control 'Name' to the top of the 'Comments'
control, we would do somthing like:

Me.Comments=Me.Name & vbcrlf & Me.Comments

We are saying make the content of the control 'Comments' equal to the text
found in the control named 'Name', goto the next line add paste whatever was
already in the 'Comments' control.

Hope this gets you started,

Daniel
 
The simple way to do this, assuming that you're talking about a fairly small
number of phrases, is as you suggested, simply adding buttons that will add
the phrases. In this example the memo box is named WorkOrder and the two
command buttons are CleanedComputer and RemovedViruses. The rest is self-
explanatory, I think.

Private Sub CleanedComputer_Click()
Me.WorkOrder.Value = Me.WorkOrder.Value & " Computer Cleaned "
End Sub

Private Sub RemovedViruses_Click()
Me.WorkOrder.Value = Me.WorkOrder.Value & " Removed Viruses "
End Sub

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000

Message posted via AccessMonster.com
 
missinglinq said:
The simple way to do this, assuming that you're talking about a fairly small
number of phrases, is as you suggested, simply adding buttons that will add
the phrases. In this example the memo box is named WorkOrder and the two
command buttons are CleanedComputer and RemovedViruses. The rest is self-
explanatory, I think.

Private Sub CleanedComputer_Click()
Me.WorkOrder.Value = Me.WorkOrder.Value & " Computer Cleaned "
End Sub

Private Sub RemovedViruses_Click()
Me.WorkOrder.Value = Me.WorkOrder.Value & " Removed Viruses "
End Sub

Thanks missinglinq, worked exactly as i pictured it...
the buttons is the simplest method, but i'll hopefully try to incorporate the
others eventually.
thanks alot for the ideas guys...
 

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

Back
Top