Results 1 to 4 of 4
  1. #1
    jamo is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    20

    reports wont open


    I am new to access, I am creating a database and I am at the reports stage. I am using the Northwind sales dialog as it is close to what I want. I tried customizing the codes but my reports wont open.I am getting the 2501 code error. This is the code
    Code:
    Sub PrintReports(ReportView As AcView)    ' This procedure used in Preview_Click and Print_Click Sub procedures.
        ' Preview or print report selected in the ReportToPrint option group.
        ' Then close the Print View Reports Dialog form.
        Dim strReportName As String
        Dim lOrderCount As Long
    
    
           
        ' Determine reporting time frame
        Select Case Me.lstImportPeriod
        Case ByYear
            strReportName = "Yearly Report"
            lOrderCount = DCountWrapper("*", "Fuel Analysis", "[Year]=" & Me.cbYear)
        Case ByQuarter
            strReportName = "Quarterly Report"
            lOrderCount = DCountWrapper("*", "Fuel Analysis", "[Year]=" & Me.cbYear & " AND [Quarter]=" & Me.cbQuarter)
        Case ByMonth
            strReportName = "Monthly Report"
            lOrderCount = DCountWrapper("*", "Fuel Analysis", "[Year]=" & Me.cbYear & " AND [Month]=" & Me.cbMonth)
        End Select
            
        If lOrderCount > 0 Then
            TempVars.Add "Group By", Me.lstImportPeriod.Value
            TempVars.Add "Display", DLookupStringWrapper("[Display]", "View Reports", "[Group By]='" & Nz(Me.lstImportPeriod) & "'")
            
            
            eh.TryToCloseObject
             DoCmd.OpenReport strReportName, ReportView, , strReportFilter, acWindowNormal
        Else
            MsgBoxOKOnly NoImportsInPeriod
        End If
    End Sub
    is there anyway I can make this code easier

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,628
    What is the exact message of the error?

    What line triggers the error?

    Step debug. Refer to link at bottom of my post on debug techniques.

    The Select Case uses a value selected in a listbox. If those values are text, then the Case condition must have those text values in quotes.

    Case "ByYear"
    ...
    Case "ByQuarter"
    ...
    Case "ByMonth"
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    tanvi is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    100
    I found a good discussion on this error: http://www.access-programmers.co.uk/...d.php?t=129491
    Hope you will find the solution from the resource!!

  4. #4
    jamo is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    20
    Thank you it opens but says there is no data. thanks

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 03-06-2012, 12:53 PM
  2. Replies: 1
    Last Post: 01-01-2012, 12:08 AM
  3. Replies: 4
    Last Post: 09-09-2011, 06:11 AM
  4. Reports w/ sub-reports very slow to open
    By vaikz in forum Reports
    Replies: 2
    Last Post: 02-27-2011, 08:41 AM
  5. Database wont open
    By sarah54 in forum Access
    Replies: 22
    Last Post: 12-08-2010, 08:38 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums