469,336 Members | 5,570 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,336 developers. It's quick & easy.

Copy from a subform to a text field in the main form

I set up an unbound subform on a main form. I need the user to be able to choose items from the sub-form and have them populate in a bound text field in the main form in paragraph style.

The sub-form is kind of like a template the user uses to document in paragraph form.

I am a bit of a novice. I would appreciate any help.
Thank You

Juan
Jun 10 '11 #1

✓ answered by jpatchak

You can just throw this code into your sub form's "On Current" event:
Expand|Select|Wrap|Line Numbers
  1. Forms!mainFormName.Form.mainTextBox.Value = Me.TextBoxNameFromSubform.Value

10 9184
You can just throw this code into your sub form's "On Current" event:
Expand|Select|Wrap|Line Numbers
  1. Forms!mainFormName.Form.mainTextBox.Value = Me.TextBoxNameFromSubform.Value
Jun 10 '11 #2
NeoPa
32,182 Expert Mod 16PB
See Referring to Items on a Sub-Form for more ways to refernce controls on your subform.
Jun 10 '11 #3
Jpatchak, thank you for your insight. I crossed the first hurdle which was getting the subform options recorded in the bound text box of the main form. The problem I have now is that it only records a single option. If the user picks a second option it replaces what it had recorded previously. I need it to record all the options the user picks in the text box.

Thank You

Juan
Jun 12 '11 #4
NeoPa
32,182 Expert Mod 16PB
You ask for help putting the data together, yet you don't give any indication of what that data together should look like.

A solution might be the following :
Expand|Select|Wrap|Line Numbers
  1. Forms!mainFormName!mainTextBox = IIf(IsNull(Forms!mainFormName!mainTextBox), _
  2.                                      "", _
  3.                                      Forms!mainFormName!mainTextBox & ",") & _
  4.                                  Me.TextBoxNameFromSubform
But frankly it's hard to know unless you make a bit more effort expressing the problem properly before posting.
Jun 13 '11 #5
NeoPa, I am sorry if I was vague. I am just try get the user to make a paragraph in a bound field of a main form from template choices in a subform.

In the click event on the unbound subform,I included:
Expand|Select|Wrap|Line Numbers
  1. variable=nz(Forms![mainform].form.bound field.value)
  2. Forms![main form].form.bound field.value= variable & chr(13) & Me![selected field in the subform].value & "."
Thank You

Juan
Jun 20 '11 #6
NeoPa
32,182 Expert Mod 16PB
I'm struggling to match this with what you requested, but a simpler form of this might be :
Expand|Select|Wrap|Line Numbers
  1. With Forms![mainform].form.[bound field]
  2.     .Value = .Value & vbNewLine & Me.ActiveControl & "."
  3. End With
I'm still guessing to a certain extent, but you might want to try it if this is what you're after.
Jun 20 '11 #7
NeoPa, thank you for your response. I will try it. I'll let you know how it goes.

Juan
Jun 20 '11 #8
NeoPa
32,182 Expert Mod 16PB
You're welcome. It's been a pleasure dealing with you Juan :-)
Jun 20 '11 #9
I am trying get everything to populate in the bound field in paragraph form. Your code works perfect except for the vbNewLine. I erased it and it gave me exactly what I was looking for.

Thank You

Juan
Jun 21 '11 #10
NeoPa
32,182 Expert Mod 16PB
My vbNewLine was simply a replacement for your Chr(13) Juan. If it works better without it then that's all good :-)

I suspect (but not sure as I don't play there much) that a bound Memo type field would display that OK, but not a Text type one. As I say though, I'm not sure.
Jun 21 '11 #11

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by prakashwadhwani | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Marylou17 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.