Refresh Source and generate report.

pedie

Well-known Member
Joined
Apr 28, 2010
Messages
3,875
Hi, I need to achieve this task please advice.</SPAN></SPAN>
I need to generate report about a 100 of them into .pdf format.
</SPAN></SPAN>
My report source is query and query refers to form controls for x criteria…
</SPAN></SPAN>

I need to make sure that my source is refreshed overtime x value in form is changed so that it will export correct report.

I have hilighted in the code ''REFRESH MY SOURCE HERE'


Below is mycode.
</SPAN></SPAN>
Code:
[/FONT][FONT=courier new]Dim x As String, y As String, z As String
Dim Rst As DAO.Recordset
Set Rst = CurrentDb.OpenRecordset("xdatatable", dbOpenDynaset)[/FONT]
[FONT=courier new]    If Not (Rst.BOF And Rst.EOF) Then
    
    Rst.MoveFirst
    While Not Rst.EOF
        [/FONT]
[FONT=courier new]            If Len(Rst![Export Fld Pth].Value & vbNullString) <> 0 Then
                z = Rst![Export Fld Pth]
            End If
        
            If Len(Rst![CC Ind].Value & vbNullString) <> 0 Then
                x = Rst![CC Ind]
                Me.Controls(x).Value = Rst![Cost Center]
            End If
        
        
            If Len(Rst![Loc Ind].Value & vbNullString) <> 0 Then
                y = Rst![Loc Ind]
                Me.Controls(y).Value = Rst![Location]
            End If
[U]
[B]'REFRESH MY SOURCE HERE[/B][/U][/FONT]
[FONT=courier new]            DoCmd.OutputTo acOutputReport, "xreport1", acFormatPDF, z & "\samplereport" & Rnd() & ".pdf", False
            
        
    Rst.MoveNext
    Wend
    
    
    End If
    
If Not Rst Is Nothing Then
    Rst.Close
    Set Rst = Nothing
End If
[/FONT]
[FONT=courier new]
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

Forum statistics

Threads
1,215,794
Messages
6,126,940
Members
449,349
Latest member
Omer Lutfu Neziroglu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top