Update another form field with drop down selection

M

magmike

I've created a table with pre-written letters. On a form, I have a
combo box that is fed by the table using the letter title and the
letter text. Then, on the AfterUpdate, the goal was to populate the
letter text box, with the 2nd column of the drop down box selection,
which is the letter body (a memo field). However, the action only
transfers a portion of the letter.

Can anyone help with this?

Thanks in advance!

magmike
 
J

John W. Vinson

I've created a table with pre-written letters. On a form, I have a
combo box that is fed by the table using the letter title and the
letter text. Then, on the AfterUpdate, the goal was to populate the
letter text box, with the 2nd column of the drop down box selection,
which is the letter body (a memo field). However, the action only
transfers a portion of the letter.

Can anyone help with this?

Thanks in advance!

magmike

A Combo Box is of limited size - I presume that the letter text is a Memo
field, and such a field will be truncated to 255 characters when it's put into
a combo.

I'd suggest having the combo's bound column be the Primary Key (LetterID I'll
call it) of the letters table, and "push" the memo from the table directly
into the textbox:

Private Sub cboLetter_AfterUpdate()
Me!txtLetterText = DLookUp("LetterText", _
"tblLetter", "LetterID=" & Me!cboLetter)
End Sub
 
M

magmike

A Combo Box is of limited size - I presume that the letter text is a Memo
field, and such a field will be truncated to 255 characters when it's putinto
a combo.

I'd suggest having the combo's bound column be the Primary Key (LetterID I'll
call it) of the letters table, and "push" the memo from the table directly
into the textbox:

Private Sub cboLetter_AfterUpdate()
Me!txtLetterText = DLookUp("LetterText", _
   "tblLetter", "LetterID=" & Me!cboLetter)
End Sub

Awesome, thanks!
 
M

magmike

A Combo Box is of limited size - I presume that the letter text is a Memo
field, and such a field will be truncated to 255 characters when it's putinto
a combo.

I'd suggest having the combo's bound column be the Primary Key (LetterID I'll
call it) of the letters table, and "push" the memo from the table directly
into the textbox:

Private Sub cboLetter_AfterUpdate()
Me!txtLetterText = DLookUp("LetterText", _
   "tblLetter", "LetterID=" & Me!cboLetter)
End Sub

If I wanted to take that text from the table and just add it to the
end of the text in the form's memo field, would that be possible as
well? I'm thinking that would be a nice tool, if one develops snippets
of text or paragraphs, and they would like to mix and match these
"snippets" to create a customized letter - that would be handy!

Thanks,
magmike
 
J

John W. Vinson

If I wanted to take that text from the table and just add it to the
end of the text in the form's memo field, would that be possible as
well? I'm thinking that would be a nice tool, if one develops snippets
of text or paragraphs, and they would like to mix and match these
"snippets" to create a customized letter - that would be handy!

Sure...


Private Sub cboLetter_AfterUpdate()
Me!txtLetterText = Me!txtLetterText & vbCrLf & DLookUp("LetterText", _
"tblLetter", "LetterID=" & Me!cboLetter)
End Sub

will insert a newline character and then the content of the LetterText field.
Leave off the vbCrLf to insert the text verbatim.
 

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

Top