473,396 Members | 2,089 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Printing subforms seaches to one report?

1
Hi there,

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
  1. 'Search data to populate form.
  2. Private Sub cmdGenerate_Click()
  3. Dim strWhere As String
  4. Dim SLSstrWhere As String
  5. Dim lngLen As Long
  6. Dim SLSlngLen As Long
  7. Const conJetDate = "\#mm\/dd\/yyyy\#"
  8. Const SLSconJetDate = "\#mm\/dd\/yyyy\#"
  9.  
  10. If Not IsNull(Me.cboAgent) Then
  11. strWhere = strWhere & "([FirstofAgent] = """ & Me.cboAgent & """) AND "
  12. End If
  13.  
  14. If Not IsNull(Me.txtStatus) Then
  15. strWhere = strWhere & "([FirstofStatus] = """ & Me.txtStatus & """) AND "
  16. End If
  17.  
  18. If Not IsNull(Me.txtStartDate) Then
  19. strWhere = strWhere & "([FirstofDepositDate] >= " & Format(Me.txtStartDate, conJetDate) & ") AND "
  20. End If
  21.  
  22. If Not IsNull(Me.txtEndDate) Then
  23. strWhere = strWhere & "([FirstofDepositDate] < " & Format(Me.txtEndDate + 1, conJetDate) & ") AND "
  24. End If
  25.  
  26. lngLen = Len(strWhere) - 5
  27. If lngLen <= 0 Then 
  28. MsgBox "No criteria", vbInformation, "There was no criteria"
  29.     Else
  30.         strWhere = Left$(strWhere, lngLen)
  31.         Debug.Print strWhere
  32.  
  33.         Me.[subform1]!Filter = strWhere
  34.         Me.[subform2]!FilterOn = True
  35.     End If
  36.  
  37. If Not IsNull(Me.cboAgent) Then
  38. SLSstrWhere = SLSstrWhere & "([SLSFirstofAgent] = """ & Me.cboAgent & """) AND "
  39. End If
  40.  
  41. If Not IsNull(Me.txtStatus) Then
  42. SLSstrWhere = SLSstrWhere & "([SLSFirstofStatus] = """ & Me.txtStatus & """) AND "
  43. End If
  44.  
  45. If Not IsNull(Me.txtStartDate) Then
  46. SLSstrWhere = SLSstrWhere & "([SLSFirstofDepositDate] >= " & Format(Me.SLStxtStartDate, SLSconJetDate) & ") AND "
  47. End If
  48.  
  49. If Not IsNull(Me.txtEndDate) Then
  50. SLSstrWhere = SLSstrWhere & "([SLSFirstofDepositDate] < " & Format(Me.SLStxtEndDate + 1, SLSconJetDate) & ") AND "
  51. End If
  52.  
  53.  
  54.     SLSlngLen = Len(strWhere) - 5
  55.     If SLSlngLen <= 0 Then 
  56.         MsgBox "No criteria", vbInformation, "There was no criteria"
  57.     Else
  58.         SLSstrWhere = Left$(strWhere, lngLen)
  59.  
  60.         Me.[subform2]!Filter = SLSstrWhere
  61.         Me.[subform2]!FilterOn = True
  62. End Sub
  63.  
  64.  
  65.  
  66. 'Send filters to report and print.
  67. Private Sub cmdReport_Click()
  68.     Dim strFilter As String
  69.     Dim SLSstrFilter As String
  70.     strFilter = Me.[subform1]!Filter
  71.     SLSstrFilter = me.[subform2]!filter
  72.     DoCmd.OpenReport "SalesReport", , , strFilter
  73. End Sub
The last code is what is hanging me up. Any help would be appreciated. FYI: I accidentally erased the code that was showing the multi record filters on the same form, I kind of put this code together from memory please excuse any errors in the top portion.
Aug 2 '10 #1
0 816

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: lobrys | last post by:
hi my question is simple : Is there a way to generate an exception when a error occurs during printing... For exemple, I want to print 4 pages of a crystal report document using...
1
by: slothboy | last post by:
Hey guys, I'm having a little trouble printing subforms. I've attached the snippet of code that prints my form which contains various subforms. It prints bounded controls on the subform just...
0
by: David Ibc | last post by:
Even printing a very small simple report there is about a 20 second delay before the report comes up. The businessobjects.com website identifies this as a problem stating that you need to set...
0
by: Ray | last post by:
Hi all, I would like to ask is there any method for printing the crystal report directly by choosing printer without previewing the report using CrystalReportViewer? Thanks a lot, Ray
0
by: waltonlv | last post by:
I have looked at several coding examples on printing an access report within VB, but am having a problem with the .OpenCurrentDatabase command. When executed, I get the message "Database is already...
4
by: .NETUser | last post by:
Hello, I am doing research on printing in VB.NET and I would like to know how I can use XML to format three different reports. I'm new to this, so I don't know how to include this in my .NET...
0
by: =?Utf-8?B?amRzdGVudG8=?= | last post by:
(I apologize if this is a repeat. I was told to post under the managed news group. I'm a little confused, but...) I'm running SRS 2000 with SP2 and I'm using IE 6.0 with SP2 (and IE 7.0) to...
4
by: paquer | last post by:
Hello' How do I get the subform to print along with the main form? I want my user's to be able to go in the field with a printout of the info they need to populate in the database. So when they...
1
by: ambelkar | last post by:
hi , Can anybody help me in printing the Crystal report in PDF format.i.e not exporting it to PDF format.When Click preview it should be displayed in PDF format.
2
by: mahesh123 | last post by:
Hi Folks, I am generating the text reports from the visual basic 6.0. while printing the text report the Char(12) ie page break character is not recognising. Is there any alternate Solution for...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.