Combine Subform field to one field on main form

A

AJ

Main Form = ModifyActionItemForm
Main Form Text Box = Text30
The record from the main form is selected in Combo23

Subform = ActionsTableSubform

Master Field = Index
Child Field = ProjectNo

I have a field called Resource in the subform. I want to combine all the
Resource fields in the subform into the text box on the Main form.

I tried this from another post I found, but it is not working, can anyone
tell me why?

Dim rs As DAO.Recordset
Dim strSQL As String, strResources As String
Dim i As Integer

strSQL = "Select ProjectNo From actionstbl" _
& " Where ProjectNo = " & Me.Combo23 & ";"

Set rs = CurrentDb.OpenRecordset(strSQL)

With rs
'get an accurate record count
..MoveLast
..MoveFirst

For i = 1 To .RecordCount
strResources = strResouces & !Resource & ", "
..MoveNext
Next i
End With

'trim off the trailing comma and space
strResources = Left(strResources, Len(strResources) - 2)

Me!Text30 = strResources

Set rs = Nothing
 

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