ge****@gmail.com wrote:
Using Access 2000.
Say you have a form that reads some table. Within this form you have a
subform that reads a given table of n records, but only displays say 5
of them. I want to take a certain cell from this subform and put all
those 5 cells from 5 different rows into a string. Bottom line is how
would one unite cells from a given column for a given number of rows of
that column into a single string that would display in a text field.
Thanks in advance.
'aircode. called form main form. pass the column name to the function
Function MakeString(strCol As String) As String
Dim rst As Recordset
'get the current set of records in the Subform
Set rst = Me("YourSubFormName").Form.RecordsetClone
If rst.RecordCount > 0 then
rst.MoveFirst
Do while Not rst.Eof
MakeString = MakeString & rst(strCol) & ", "
rst.MoveNext
Loop
'remove comma/space
MakeString = Left(MakeString,Len(MakeString)-2)
ENdif
rst.close
set rst = Nothing
End Function
Change it so the recordset points to your subform name. How it would work.
Dim strCell = MakeString("FieldName1")
and this would assign to strCell the values from FieldName1