Unbound Control in a Report Not Printing - Help

  • Thread starter Thread starter Luis
  • Start date Start date
L

Luis

I have a report that needs to print a detail line item from an unbound
control.
I read a database to populate this unbound control (see code below). However,
the problems that I'm having is that the vba code works correct meaning that
it retrieves the information but the report (unbound control) does not show
the information when the report print but it is in the unbound control.

Can someone give me guidance to enable me to print the detail line instead of
not printing anything?

Thank you for guidance.

Luis

CODE:
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
Call F35detailPoc(unboundF35Line)
Me.POC = unboundF35Line
End Sub

Function F35detailPoc(unboundF35Line)
Dim dbs As DAO.Database
Dim rs As DAO.Recordset
Dim strRead As String

strRead = "SELECT [tblAwardFeeF-35contact].[F-35Contact] " _
& "FROM [tblAwardFeeF-35contact]" _
& "WHERE ((([tblAwardFeeF-35contact].Period)=" & Me.Period & ")" & "
AND (
([tblAwardFeeF-35contact].Phase)=" & "'" & Me.Phase & "')" & " AND ((
[tblAwardFeeF-35contact].EvaluationArea)=" & "'" & Me.EvaluationArea
& "')" &
" AND (([tblAwardFeeF-35contact].[Item No])=" & Me.Item_No & "))"

Set dbs = CurrentDb()
Set rs = CurrentDb.OpenRecordset(strRead)
With rs
Do Until rs.EOF
Debug.Print "rs field = " & rs![F-35Contact] &
unboundF35Line
unboundF35Line = unboundF35Line + rs![F-35Contact] &
vbNewLine
.MoveNext
Loop
End With

Set rs = Nothing
End Function
 
Hi Luis,
try in this way
CODE:
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
Me.POC = F35detailPoc()
End Sub

Function F35detailPoc() as string
Dim dbs As DAO.Database
Dim rs As DAO.Recordset
Dim strRead As String

strRead = "SELECT [tblAwardFeeF-35contact].[F-35Contact] " _
& "FROM [tblAwardFeeF-35contact]" _
& "WHERE ((([tblAwardFeeF-35contact].Period)=" & Me.Period & ")" & "
AND (
([tblAwardFeeF-35contact].Phase)=" & "'" & Me.Phase & "')" & " AND
((
[tblAwardFeeF-35contact].EvaluationArea)=" & "'" & Me.EvaluationArea
& "')" &
" AND (([tblAwardFeeF-35contact].[Item No])=" & Me.Item_No & "))"

Set dbs = CurrentDb()
Set rs = CurrentDb.OpenRecordset(strRead)
With rs
Do Until rs.EOF
Debug.Print "rs field = " & rs![F-35Contact] &
unboundF35Line
unboundF35Line = unboundF35Line + rs![F-35Contact] &
vbNewLine
.MoveNext
Loop
End With
F35detailPoc = unboundF35Line
Set rs = Nothing
End Function

HTH Paolo
 
Back
Top