add one field, multiple records

T

traygo

Didn't even know what to search for, lets see if I can explain this.

Owners have multiple land parcels, each parcel having several
attributes, including [legalDescription]. I want to add the text
string together from all (could be just one parcel, or many parcels)
parcels to get one text box that shows all the legal descriptions
strung together, per Owner.

I plan on having Parcel records on subform1, and the "strung together"
legal description as a text box on main form. How can I co this? I
guess it's possible that all the legal descriptions together for one
owner could exceed 255 characters, and thats ok to truncate.

Thanks
 
T

traygo

I was able to do what I needed, using a Do..Loop statement which puts
the data from each records field into one string.

I use:
Dim RS As DAO.Recordset
Dim strResult As String

Set RS = CurrentDb.OpenRecordset("qryConcatLegalDesc")

If RS.RecordCount = 0 Then
MsgBox "no records"
Exit Sub
End If

Do While Not RS.EOF
strResult = strResult & "; " & RS!legal
RS.MoveNext
Loop

RS.Close
Set RS = Nothing

This works, but it puts a "; " at the beginning of the string. How
can I either:
1. not put the "; " for the first record
or
2. after the string is completed, strip off the first "; ". (there
will be more "; ", so can't use Replace.

Thanks.
 

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