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

Append text

Status
Not open for further replies.

Mel90

Technical User
Jun 20, 2006
3
US
How can I populate a memo or text field in a form with data from 2 or more combo boxes in a subform? For instance, if in the subform combo1="Jane Doe" and combo2="John Doe", the new field in the main form should automatically read "Jane Doe, John Doe". Any suggestions?
 
How are ya Mel90 . . .

Here's a function to get you started. In the code module of the form, copy/paste the following, [blue]you![/blue] substitute proper names in [purple]purple[/purple]:
Code:
[blue]Public Function PackCombos()
   Dim x As Integer, ctlName As String, Pack As String
   
   For x = 1 To 2
      ctlName = Choose(x, "[purple][b]ComboName1[/b][/purple]", "[purple][b]ComboName2[/b][/purple]")
      
      If Pack = "" Then
         Pack = Me(ctlName)
      Else
         Pack = Pack & ", " & Me(ctlName)
      End If
      
      PackCombos = Pack
End Function[/blue]
The question is where to copy/trigger the code . . . at present I'm thinking a [blue]Command Button[/blue]

[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .
 
Thanks so much for your quick response, TheAceMan1. Unfortunately, it's not quite what I needed to fix this perplexing problem. I apologize that I may not have posed my question clearly. In essence, I'm using a subform (datasheet style) with a combo box for the individual's name. Once selected, I'd like this name (John Doe) to be copied into a control on my main form. If there's a second individual to be added, I would return to my subform and select the same combo box in the next record (Jane Doe). So, ultimately, there would be 2 records in my subform. Each name selected (from the same combo box, but creating 2 records) would be copied to my main form separated by a comma. I.e., "John Doe, Jane Doe". I feel that I'm close as I have written an iif statement that picks up the name from the first record, but it's overwritten when subsequent names (records) are added. Thanks in advance for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top