Trouble with batch reports

shenty

Registered User.
Local time
Today, 21:39
Joined
Jun 8, 2007
Messages
119
Hi all

I am having trouble with some code for printing batch reports. I created a form with a load of tick boxes. There names are Report1, Report2 Report3 etc etc.....

I have the following code to loop through which text boxes are ticked and to preview the necessary but one line is not doing what i want it to !!

Code:
    Dim stDocName(18) As String
    stDocName(1) = "rptMedicineNotEmpty"
    stDocName(2) = "rptTBTest"
    stDocName(3) = "rptDryingOff"
    stDocName(4) = "rpt30month"
    stDocName(5) = "rptFootTrimming"
    stDocName(6) = "rptAnimalsON"
    stDocName(7) = "rptAnimalsOFF"
    stDocName(8) = "rptCalvingRecord"
    stDocName(9) = "rptAIRegister"
    stDocName(10) = "rptFootTrimmingRecord"
    stDocName(11) = "rptMedicinePurchased"
    stDocName(12) = "rptMedicineAdminDryCows"
    stDocName(13) = "rptMedicineAdminMastAug"
    stDocName(14) = "rptMedicineAdminFCMDR"
    stDocName(15) = "rptMedicineAdminCalfYoung"
    stDocName(16) = "rptMedicineAdminTestVaccWorm"
    stDocName(17) = "rptMedicineAdminCowLame"
    stDocName(18) = "rptMedicineAdminSheep"
    If Me.ToDate < Me.FromDate Or IsNull(Me.FromDate) Or Me.FromDate = "" Then
        MsgBox "Invalid date range", vbOKOnly, "Error"
        Me.FromDate.SetFocus
        Exit Sub
    End If
    For a = 1 To 18
        [COLOR=red]If Me.Report(a) = True Then[/COLOR]
            StartDate = Me.FromDate
            EndDate = Me.ToDate
            ReportName = stDocName(a)
            DoCmd.OpenReport ReportName, acPreview
        End If
    Next a

Exit_Command5_Click:
    Exit Sub
Err_Command5_Click:
    MsgBox Err.Description
    Resume Exit_Command5_Click

The error is Method or Data Member not found !!

The form jpeg is attached.

Could anyone help ?
 

Attachments

  • batch reports.JPG
    batch reports.JPG
    36.4 KB · Views: 162
It's the way you are trying to reference you control names that causing it.

try

If Me("Report" & a) = True Then
 
Brilliant - thanks.

Maybe you can help me on my next problem that i haven't started on yet !!! In the same db i am going to create a multi select listbox. I want to be able to select multiple record entries and print a report for each one.

How would you suggest i do that.

Thanks again
 
in that setup you would loop through all items selected and print them accordingly

Sample:
Dim VarItem As Variant
For Each VarItem In Me!List0.ItemsSelected
Value = List0.Column(1, RowSelected)
Forms![Search_Articles].[RecordSource] = "Select * From Articles Where article_subject = '" & Value & "'"
Next VarItem

Do an F1 on ItemSelected for a clearer solution

David
 
Great - thank you very much, this one is working fine - now onto the other.
 

Users who are viewing this thread

Back
Top Bottom