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

Autofill a Memo Field

Status
Not open for further replies.

crisis2007

Technical User
Apr 2, 2007
114
US
I am trying to figure a way to autofill a textbox field based on the selection from a dropdown on a combobox. But I want to still be able to add to the text that then becomes visible.The controls are on a form that I will use to input data. And I am using Access 97. Pretty new to adding code but can get lucky now and then.
 
Hi. First, why do you want to do this? Why copy data into two different places? Why not just have a field in your table that stores the data selected by the combo box on your form? What if a person picks something from the combo box, then picks something else, then something else? do you want to continue to add the selection(s) into a long string of text? Seems odd to me....

That being said, in the AfterUpdate of the combo box, you can put

Me.memofield = me.memofield & me.comboboxname

That will just append the selection to the text that is already in the memo field. Again, I advise against this. Maybe if you tell us more about what you are doing, we can provide a better solution.

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244. Basics at
 
I guess I was not clear enough. I am not trying to duplicate the data from one box to another. I just want to have a certain phrase show up in the texbox after selecting an item from the combobox. For example, if I have a list of days in the dropdown of the combobox and I select "Sunday", then the textbox would autofill "Wash the car" But I want to be able to type in additional text in the textbox in addition to "Wash the Car
 
So, where does "Wash The Car" come from? Doesn't it come from perhaps the table that is the rowsource for the combo box?

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244. Basics at
 
No. It is basically just a prompt so that the user includes certain information into the field.
 
Ok, sorry but this doesn't make any sense.

A user picks something from a list in a combo box.

Some unknown text that comes from an unknown place is pasted into a memo field. This text is unknown, so therefore nothing will be pasted there.

Is that right?

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244. Basics at
 
I am still not explaining well enough. The text is known - something that I already put in code to show in the textbox, i.e. "Wash the car". So in other words, anytime I pick the item "Sunday' from the combobox, the words "Wash the car" will populate the memo field. Then I need to be able to manually add text in the memo field after the "Wash the car" phrase had populated the field, so the field would then say, "Wash the car" and whatever I decide to type after it.


 
I am still not explaining well enough. The text is known - something that I already put in code to show in the textbox, i.e. "Wash the car". So in other words, anytime I pick the item "Sunday' from the combobox, the words "Wash the car" will populate the memo field of the related textbox. Then I need to be able to manually add text in the memo field after the "Wash the car" phrase had populated the field, so the field would then say, "Wash the car" and whatever I decide to type after it.


 
So, where is this code?

Still don't get it totally, but essentially if you put in the combo box's OnChange event, put

Me.MemoFieldName = Me.MemoFieldName & " " & Me.ComboBoxName

it will add what is in the combo box to the memo field.

If you want what is in Column 2, say, of the combo box, put

Me.ComboBoxName.column(1)

If you want a comma in between the existing memo field data and the additional combo box data, put a comma (or semi-colon or whatever you want) in between the parentheses above.



Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244. Basics at
 
Thanks for your help. I guess I am having difficulty explaining it well enough. I appreciate your patience.I can I can work with what you supplied. But I did not want what was selected in the combobox to show up in the textbox - it was just to perhaps trigger a code to put in the phrase "wash the car" in the text box. Then the user would add a sentence to the phrase "wash the car" in the same textbox.
 
The OP is simply using the combobox to add boilerplate text to the memo field, thus saving data entry time. I've used it before for such things as nursing notes, which tend to be very repetitive.

Instead of typing

"Bilateral breath sounds equal and clear to auscultation and palpation. No rales, wheezing or rhonchi noted. Cough dry and non-productive."

twenty or thirty times a shift, the nurse can simply select "Normal pulmonary exam" from a combobox and the above text will be inserted into the memo field. If the memo field isn't locked, the user can then add to these notes.

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
Yes, thanks Missingling, your example is what I was trying to ask.
 
Forgot to add that Ginger's code

Code:
[b]Me.MemoFieldName = Me.MemoFieldName & " " & Me.ComboBoxName[/b]

will add the boilerplate text to the text box and you'll still be able to add text manually, assuming that you haven't done something to the memo field's control to prevent this.

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
Well, that's what I was trying to ask way up top: isn't

"Bilateral breath sounds equal and clear to auscultation and palpation. No rales, wheezing or rhonchi noted. Cough dry and non-productive."

or

"Wash the car"

someplace in a table some where? Surely it is. Like maybe in the same table as

"Normal pulmonary exam"

or

"Sunday"

only in another field?

So in the combo box, they pick Sunday or "Normal pulmonary exam" but the other big long thing is in like column(1) or column(2) of the combo box? Feeling like I'm a crazy person..................






Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244. Basics at
 
Not crazy. I just did not look at it the same way you were. I was not thinking about something added into a table. But I see now that it is a great way in taking care of it. I am sure it will work for me. I was originally thinking at it by way of just adding a piece of code attached to the memofield that would add the phrase when the item "sunday" was chosen in the combobox. Your way seems much easier for me. All the same, I appreciate your help! I haven't had time to try it yet as I had been called away but will make a go at it hopefully later today. Thanks again to both of you!!!!!
 
I always use a table for this purpose, as it allows you to change the boilerplate without accessing the code. Evem in an .MDE file, the end users can make these changes themselves, with just the addition of a simple form run up for the purpose!

But for a small list of simple items you could actually use the Select Case construct to assign the values to the memo field:

Code:
Select Case YourMemoBox
  Case "Sunday"
   Me.MemoFieldName = Me.MemoFieldName & " Wash the car!"
  Case "Monday" 
   Me.MemoFieldName = Me.MemoFieldName & " Take in laundry!"
  Case Else
End Select

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top