Hello all,
This relates to a previous SOLVED post of mine and the use of a Form to show records based on an Action Table (previous post discussed email attachments).
The form (FActions) also has a subform (TLinks_subform) shown which allows Users to record references (record numbers) for associated "Linked" records from other tables.
The form has a print button that opens a report and prints the content of the current record fields to a PDF output. This largely works but now I want to include the subform records and append the names of any found (may be multiple links) to one of the text boxes in the printed report.
The code I'm playing with is as follows...
Private Sub Report_Open(Cancel As Integer)
' Add Links references for each any every linked file
Dim rs As DAO.Recordset
Dim strFile As String
Set rs = [Forms]![FActions]![TLinks_subform].Form.RecordsetClone
With rs
If Not (.BOF And .EOF) Then .MoveFirst
While Not .EOF
' Set file (linked record name)
strFile = Link
MsgBox strFile
If strFile <> "" Then
' add the link reference to textbox "text4" in report
Me.Text4 = Me.Text4 & strFile & ", "
End If
.MoveNext
Wend
.Close
End With
Set rs = Nothing
End Sub
The msgbox entry (for diagnostics) confirms that it is able to identify 3 linked records (the msgbox appears three times for my test record) but for some reason displays blank i.e. strfile ="".
Any suggestions on where I am going wrong would be gratefully appreciated.
This relates to a previous SOLVED post of mine and the use of a Form to show records based on an Action Table (previous post discussed email attachments).
The form (FActions) also has a subform (TLinks_subform) shown which allows Users to record references (record numbers) for associated "Linked" records from other tables.
The form has a print button that opens a report and prints the content of the current record fields to a PDF output. This largely works but now I want to include the subform records and append the names of any found (may be multiple links) to one of the text boxes in the printed report.
The code I'm playing with is as follows...
Private Sub Report_Open(Cancel As Integer)
' Add Links references for each any every linked file
Dim rs As DAO.Recordset
Dim strFile As String
Set rs = [Forms]![FActions]![TLinks_subform].Form.RecordsetClone
With rs
If Not (.BOF And .EOF) Then .MoveFirst
While Not .EOF
' Set file (linked record name)
strFile = Link
MsgBox strFile
If strFile <> "" Then
' add the link reference to textbox "text4" in report
Me.Text4 = Me.Text4 & strFile & ", "
End If
.MoveNext
Wend
.Close
End With
Set rs = Nothing
End Sub
The msgbox entry (for diagnostics) confirms that it is able to identify 3 linked records (the msgbox appears three times for my test record) but for some reason displays blank i.e. strfile ="".
Any suggestions on where I am going wrong would be gratefully appreciated.