I'm trying to create a report from a form with several subforms, but when i try to view the report, Access just sends the information into 1000+ pages. It was kind of simple to create one form to one report. What i'm trying to do is have one form take similar fields and pull up records for 2 subforms, this form helps my company figure out payroll for sales as the reps get paid on front end and back end, so multi date searches are necessary, they would also like having one report that contains both sets of data as these reports are printed and distributed with pay checks.
Expand|Select|Wrap|Line Numbers
- 'Search data to populate form.
- Private Sub cmdGenerate_Click()
- Dim strWhere As String
- Dim SLSstrWhere As String
- Dim lngLen As Long
- Dim SLSlngLen As Long
- Const conJetDate = "\#mm\/dd\/yyyy\#"
- Const SLSconJetDate = "\#mm\/dd\/yyyy\#"
- If Not IsNull(Me.cboAgent) Then
- strWhere = strWhere & "([FirstofAgent] = """ & Me.cboAgent & """) AND "
- End If
- If Not IsNull(Me.txtStatus) Then
- strWhere = strWhere & "([FirstofStatus] = """ & Me.txtStatus & """) AND "
- End If
- If Not IsNull(Me.txtStartDate) Then
- strWhere = strWhere & "([FirstofDepositDate] >= " & Format(Me.txtStartDate, conJetDate) & ") AND "
- End If
- If Not IsNull(Me.txtEndDate) Then
- strWhere = strWhere & "([FirstofDepositDate] < " & Format(Me.txtEndDate + 1, conJetDate) & ") AND "
- End If
- lngLen = Len(strWhere) - 5
- If lngLen <= 0 Then
- MsgBox "No criteria", vbInformation, "There was no criteria"
- Else
- strWhere = Left$(strWhere, lngLen)
- Debug.Print strWhere
- Me.[subform1]!Filter = strWhere
- Me.[subform2]!FilterOn = True
- End If
- If Not IsNull(Me.cboAgent) Then
- SLSstrWhere = SLSstrWhere & "([SLSFirstofAgent] = """ & Me.cboAgent & """) AND "
- End If
- If Not IsNull(Me.txtStatus) Then
- SLSstrWhere = SLSstrWhere & "([SLSFirstofStatus] = """ & Me.txtStatus & """) AND "
- End If
- If Not IsNull(Me.txtStartDate) Then
- SLSstrWhere = SLSstrWhere & "([SLSFirstofDepositDate] >= " & Format(Me.SLStxtStartDate, SLSconJetDate) & ") AND "
- End If
- If Not IsNull(Me.txtEndDate) Then
- SLSstrWhere = SLSstrWhere & "([SLSFirstofDepositDate] < " & Format(Me.SLStxtEndDate + 1, SLSconJetDate) & ") AND "
- End If
- SLSlngLen = Len(strWhere) - 5
- If SLSlngLen <= 0 Then
- MsgBox "No criteria", vbInformation, "There was no criteria"
- Else
- SLSstrWhere = Left$(strWhere, lngLen)
- Me.[subform2]!Filter = SLSstrWhere
- Me.[subform2]!FilterOn = True
- End Sub
- 'Send filters to report and print.
- Private Sub cmdReport_Click()
- Dim strFilter As String
- Dim SLSstrFilter As String
- strFilter = Me.[subform1]!Filter
- SLSstrFilter = me.[subform2]!filter
- DoCmd.OpenReport "SalesReport", , , strFilter
- End Sub