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

Populate Textbox or Memo field on one form with data from another form

Status
Not open for further replies.

henley12

Programmer
Mar 26, 2004
17
0
0
US
I am writing a maintenance database and I have a button on my form that opens another form with a list of checkboxed items on it. I need to populate the memo field on the first form with the items selected. I'm sure there is an easy way to do this, but it escapes me at the moment. Please help.
 
What property of the checkbox do you wish to write to the form? For example:

Code:
For Each ctl In Me.Controls
   If ctl.ControlType=acCheckBox Then
       If ctl=True Then
           strList=strList & vbCrLf ctl.Name
       End If
   End If
Next

Forms!FirstForm!Memo=strList
 
. . . or better yet, give us some assemblance of how you wish to view/format the memo! . . .

Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 
The checkboxes will have text beside them which I want to show up in the memo field, each on a separate line, depending on what was checked.
 
Name the textboxes with the same name as the checkboxes, except for a prefix, say "t":

Code:
For Each ctl In Me.Controls
   If ctl.ControlType=acCheckBox Then
       If ctl=True Then
           strList=strList & vbCrLf Me("t" & ctl.Name).Value
       End If
   End If
Next

Forms!FirstForm!Memo=strList

 
That will depend on your application. The close event or a button may be most suitable. Be aware that the above is a rough snippet, not complete code.
 
I am getting an error. What am I missing? The code stops on this line:

strList = strList & CRLF & Me("t" & ctl.Name).Value


And the error says "Object doesn't support this property or method.
 
I suggested vbCrLf, it is carriage return and line feed. You could use any other separator that suited.

[tt]strList = strList & vbCRLF & Me("t" & ctl.Name).Value[/tt]
 
This is still not working for me. I am programming in Access 2007. I hope I am explaining what I want clearly. My main form has a command button next to a memo field. When I click the command button, another form opens up with 4 checkboxes. I want the label of those checkboxes to show up on my main form when I select them and close the form.
 
Please post the code as amended by you to suit your application.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top