Creating Report Data on the Fly

txgeekgirl

Registered User.
Local time
Today, 03:54
Joined
Jul 31, 2008
Messages
187
I have a Form that produces a scripted response in paragraph form.


FROM POIPreview:


Code:
Private Sub Form_Load()
 
    Dim MyStr As String
    Dim Q2 As String
    Dim Q3 As String
    Dim Q4 As String
 
    Me.tbFindings = MyID
 
    If DLookup("CH2", "Findings", "[FindingID] = " & Me.tbFindings) = True Then
        Q2 = " At this time I am requesting training regarding the area of deficiency. "
        Q2 = Q2 & "Specifically I am requesting: " & DLookup("CH2Text", "Findings", "[FindingID] = " & Me.tbFindings)
    Else
        Q2 = ""
    End If
 
    If DLookup("CH3", "Findings", "[FindingID] = " & Me.tbFindings) = True Then
        Q3 = " At this time I believe the Audit does not reflect the program performance and am requesting mediation with the DED . "
        Q3 = Q3 & "Specifically: " & DLookup("CH3Text", "Findings", "[FindingID] = " & Me.tbFindings)
    Else
        Q3 = ""
    End If
 
    If DLookup("CH4", "Findings", "[FindingID] = " & Me.tbFindings) = True Then
        Q4 = " Audit Findings were due to management issues with staff. "
        Q4 = Q4 & "Specifically: " & DLookup("CH4Text", "Findings", "[FindingID] = " & Me.tbFindings)
    Else
        Q4 = ""
    End If
 
    ' Write Summary
     MyStr = "In response to the Finding/Trend: " & DLookup("POIDetails", "Findings", "[FindingID] = " & Me.tbFindings)
     MyStr = MyStr & vbNewLine & vbNewLine & " I contacted " & DLookup("Auditor", "Findings", "[FindingID] = " & Me.tbFindings) & " on "
     MyStr = MyStr & DLookup("ContactDate", "Findings", "[FindingID] = " & Me.tbFindings) & " to discuss the Audit Findings."
     MyStr = MyStr & Q2 & Q3 & Q4
     MyStr = MyStr & vbNewLine & vbNewLine & " The corrective action I plan to take is the following: " & DLookup("POICorAction", "Findings", "[FindingID] = " & Me.tbFindings)
     MyStr = MyStr & vbNewLine & vbNewLine & " My plan to oversight the corrective action to ensure future compliance is: " & DLookup("POIOversight", "Findings", "[FindingID] = " & Me.tbFindings)
     MyStr = MyStr & " This POI will be implemented by: " & Str(DLookup("POIImpDate", "Findings", "[FindingID] = " & Me.tbFindings))
 
    Me.tbMemoPreview = MyStr
 
 
End Sub

I briefly open this window so it writes the scripted response


Code:
Sub Print_Report()
    DoCmd.Minimize
 
    DoCmd.OpenForm "POIPreview"
    DoCmd.Minimize
    DoCmd.OpenReport "POIResponse", acViewPreview
 
End Sub

But it will NOT allow me to use what is contained in the Form to fill the report.... Since we are NOT storing the scripted responses, I have to fill off the form. Any suggestions??? :confused:


Code:
Private Sub Report_Open(Cancel As Integer)
    Me.rpPOIResponse = [Forms]![POIPreview]![tbMemoPreview]
End Sub
 
To explicitly set the value of an unbound control on a report try handling the format event of the section in which that control appears. Under normal circumstances sections of reports are repeated as often as required as dictated by the data provided to that report. As such it's not really meaningful to provide data to a control in the Open event of a report, rather it will be in each iteration of the formatting of the section in question in which the value of the control is 'up for grabs.'
HTH
 
This is a one shot - print out what they submitted to QA - shut the window. But they need to be able to select their network printer and it needs to be date time stamped. Therefore a report would work great.

So - you are right - this is not a flow/list of data - one shot/one record.
 
Ahhh, does that mean you solved this? Did you handle the format event of a report section using code like ...
Code:
Private Sub ReportHeader_Format(Cancel As Integer, FormatCount As Integer)
   Me.Text0 = [Forms]![POIPreview]![tbMemoPreview]
End Sub
Cool,
 
No - I left it alone because I didn't know how to handle it.

So you are saying adding a FormatCount will handle the displaying of the code onto a report?

I actually tried to figure out how to have the EUs print their form - but most can't even tie their shoes. It's a situation where if it isn't coded then I get stuck storing the value to reproduce it - which I don't want to do.
 
I took it out of the VBA code and put it as a control source and it is working fine. On close, it closes the report and opened preview source. :rolleyes:

Man - I hate when things are simple but they aren't.
 

Users who are viewing this thread

Back
Top Bottom