Merging multiple rows from a single field into a textbox

I made you a little demo db (A2003)

Open form Table1Form and then click the label Macro1 and the entried will be made in Table2Form.

The way I have there are 2 spaces between each.

But you have to do some yourself:)

Go to Macro 1 in Design view. As you see the actions are being repeated but that is only satisfactory for a demo. You need to macros. The first gets things going with some actions and then has a RunMacro action. The RunMacro action basically repeats the step. When you select RunMacro action you will see you have a Repeat Count and a Repeat Expression.

The Repeat Count can be a number. But that is no good because you don't know how many records there will be. You can also enter an expression like =[Forms]![FormName]![TextBoxName]. TextboxName could be a count of the records.

But the more common way is Repeat Expression and is will be based on the records ending.

If you don't want the spaces then just delete the RunCode action lines.

Instead of F2 (twice) you can use

Public Function EndofField()
Forms![ProspectNotes]!ActdateComments.SetFocus
Forms![ProspectNotes]!ActdateComments.SelStart = Len(Forms![ProspectNotes]!ActdateComments.Text)
Forms![ProspectNotes]!ActdateComments.SelLength = 0
End Function

and call that with RunCode.

To go through your whole record set on the main form you SelectObject for the form and NextRecord at the end of the "inserting process" actions on the macro that is being run by the RunMacro action.

As I mentioned earlier you can't have any Null field for the Copy action so have your query eliminate any of those.

Hope that gets you going.
 

Attachments

PS,

One thing I forgot to mention is to put GoToRecord and First at the start. And you might wsant to add a Sort from RunCommand.

Just remember that it will just go down the records in whatever order they are in. kind of a mechanical thing
 
I just stumbled across something that with modification could be good.

http://www.access-programmers.co.uk/forums/showthread.php?t=99777

This is thread on sample data bases made by member KenHigg. Go to the 5th post and "consolidate"

It puts the data (form one field) from all records with the same ID into a single field
 

Users who are viewing this thread

Back
Top Bottom